Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#24981 closed Uncategorized (invalid)

Importing an abstract model from a bare package fails.

Reported by: Stavros Korokithakis Owned by: nobody
Component: Uncategorized Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have an abstract model called CharIDModel in myproject/utils/ If I import it as "from utils import CharIDModel" and inherit from it, makemigrations crashes with:

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

Change History (2)

comment:1 Changed 7 years ago by Tim Graham

Resolution: invalid
Status: newclosed

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!

comment:2 Changed 7 years ago by Stavros Korokithakis

Thank you, I'll just upgrade to 1.8!

Note: See TracTickets for help on using tickets.
Back to Top