Opened 7 years ago

Closed 7 years ago

#8195 closed (worksforme)

Importing models from same directory throws unhelpful exception (trying to get app_label)

Reported by: kcarnold Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: kenneth.arnold@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:



In [1]: import models
<type 'exceptions.IndexError'>            Traceback (most recent call last)
 (strip my stuff)
...django/db/models/ in __new__(cls, name, bases, attrs)
     54             # For 'django.contrib.sites.models', this would be 'sites'.
     55             model_module = sys.modules[new_class.__module__]
---> 56             kwargs = {"app_label": model_module.__name__.split('.')[-2]}
     57         else:
     58             kwargs = {}

After attached patch, the relative import succeeds.

Attachments (1)

django-relative-import-app-label.patch (1.2 KB) - added by kcarnold 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by kcarnold

comment:1 Changed 7 years ago by kcarnold

  • Cc kenneth.arnold@… added
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by mtredinnick

You haven't clearly explained the problem you are trying to fix. There's lots of code around that does import models without any problems, so that particular line of code isn't fundamentally broken.

Please provide some steps to replicate the problem you are seeing, then we can work out if the solution is appropriate.

comment:3 Changed 7 years ago by jacob

  • Resolution set to worksforme
  • Status changed from new to closed

Marking worksforme; kcarnold, please feel free to reopen when you provide the details Malcolm asked for.

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