Opened 5 years ago

Closed 5 years ago

#14542 closed (invalid)

Short model names break

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

Description

One-character model names appear to break Django:

>>> class A(models.Model):
...    pass
... 
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 48, in __new__
    kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range

Change History (1)

comment:1 Changed 5 years ago by Personman

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Oopsies. Apparently something else is wrong, because this happens with names of any other length, too:

class Parent(models.Model):

... bar = models.ForeignKey('Foo')
...
Traceback (most recent call last):

File "<console>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 48, in new

kwargs = {"app_label": model_module.name.split('.')[-2]}

IndexError: list index out of range

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