Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24287 closed Cleanup/optimization (fixed)

A model outside an app causes inane error

Reported by: jMyles Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

To reproduce:

Create a models.py in the root of a project (ie, next to manage.py). Create a class in it that inherits from django.db.models.Model.

This causes IndexError to be raised in the new because package_components will be only models, without the app name, ie, this line:

kwargs = {"app_label": package_components[app_label_index]}

Of course, the proper thing to do is to create an app, but new users may not realize this and, given this error, may not know on what topic to seek assistance.

Change History (4)

comment:2 by Tim Graham, 10 years ago

Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

I believe #21680 is related.

comment:3 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In ac576e9f454db4942335a9a5df6168d31d4f98fe:

[1.8.x] Fixed #24287 -- Added friendly error if a model is in a models.py outside an installed app.

comment:4 by Tim Graham <timograham@…>, 10 years ago

In eb406aa686ff1809903366ef6896037af2f1f69b:

[1.8.x] Silenced deprecation warning in refs #24287 test.

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