[Django] #24981: Importing an abstract model from a bare package fails.

7 views
Skip to first unread message

Django

unread,
Jun 13, 2015, 6:20:23 PM6/13/15
to django-...@googlegroups.com
#24981: Importing an abstract model from a bare package fails.
-------------------------------+--------------------
Reporter: skorokithakis | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I have an abstract model called CharIDModel in
myproject/utils/__init__.py. If I import it as "from utils import
CharIDModel" and inherit from it, makemigrations crashes with:

{{{
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/user/.virtualenvs/project/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "/home/user/.virtualenvs/project/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/user/.virtualenvs/project/local/lib/python2.7/site-
packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/user/.virtualenvs/project/local/lib/python2.7/site-
packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/user/.virtualenvs/project/local/lib/python2.7/site-
packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
import_module
__import__(name)
File "/home/user/Code/Django/project/main/models.py", line 11, in
<module>
from utils import dt_today, CharIDModel
File "/home/user/Code/Django/project/utils/__init__.py", line 48, in
<module>
class CharIDModel(models.Model):
File "/home/user/.virtualenvs/project/local/lib/python2.7/site-
packages/django/db/models/base.py", line 115, in __new__
kwargs = {"app_label": package_components[app_label_index]}
IndexError: list index out of range
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24981>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 13, 2015, 7:19:10 PM6/13/15
to django-...@googlegroups.com
#24981: Importing an abstract model from a bare package fails.
-------------------------------+--------------------------------------
Reporter: skorokithakis | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.8
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

Based on the traceback, it looks like you're using Django 1.7. In Django
1.8 it looks like that `IndexError` is caught and you should get an error
message like 'Unable to detect the app label for model "%s." Ensure that
its module, "%s", is located inside an installed app.'" You might try
adding an explicit `Meta.app_label` to your abstract model. Feel free to
reopen if you continue to suspect a bug and can provide a sample project
running Django 1.8, as 1.7 is only receiving security updates at this
time. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/24981#comment:1>

Django

unread,
Jun 13, 2015, 7:19:53 PM6/13/15
to django-...@googlegroups.com
#24981: Importing an abstract model from a bare package fails.
-------------------------------+--------------------------------------
Reporter: skorokithakis | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.8
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by skorokithakis):

Thank you, I'll just upgrade to 1.8!

--
Ticket URL: <https://code.djangoproject.com/ticket/24981#comment:2>

Reply all
Reply to author
Forward
0 new messages