#15866 closed Bug (fixed)
get_model() and get_models() can return models that are not in INSTALLED_APPS
| Reported by: | Carl Meyer | Owned by: | Carl Meyer |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | |
| 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: | no |
Description
register_models() does not check if the app is present in INSTALLED_APPS, and so importing a models.py file will cause that apps' models to be available via get_model() or get_models(), even though the app is not installed (meaning it has no database tables, so actually using those models is almost certain to cause a database error).
Change History (7)
comment:1 by , 15 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
comment:3 by , 15 years ago
| Has patch: | set |
|---|
Candidate fix for this with test here: https://github.com/carljm/django/compare/master...t15866
comment:4 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
In [16053]:
(The changeset message doesn't reference this ticket)
follow-up: 6 comment:5 by , 15 years ago
| Easy pickings: | unset |
|---|
This should really have been added to the app-loading branch, not trunk.
comment:6 by , 15 years ago
Replying to jezdez:
This should really have been added to the app-loading branch, not trunk.
I don't mind porting this fix to app-loading branch, but fixing it in trunk resolved a problematic regression (#15850) which prevented reusable app authors from running their tests against trunk. I wouldn't want to delay that fix until app-loading lands, though if having this in trunk is a serious problem we could temporarily use a hackier workaround to resolve #15850.
#15850 is the most immediately problematic symptom of this bug.