Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#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 Carl Meyer, 14 years ago

Owner: changed from nobody to Carl Meyer
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by Carl Meyer, 14 years ago

#15850 is the most immediately problematic symptom of this bug.

comment:3 by Carl Meyer, 14 years ago

Has patch: set

Candidate fix for this with test here: https://github.com/carljm/django/compare/master...t15866

comment:4 by Carl Meyer, 14 years ago

Resolution: fixed
Status: assignedclosed

In [16053]:

(The changeset message doesn't reference this ticket)

comment:5 by Jannis Leidel, 14 years ago

Easy pickings: unset

This should really have been added to the app-loading branch, not trunk.

in reply to:  5 comment:6 by Carl Meyer, 14 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.

comment:7 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In 9f13c3328199d2fa70235cdc63bb06b1efc5b117:

Removed the only_installed argument of Apps.get_models.

Refs #15903, #15866, #15850.

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