summaryrefslogtreecommitdiff
path: root/django/apps/config.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2016-05-03 12:21:54 +0200
committerTim Graham <timograham@gmail.com>2016-10-28 19:08:57 -0400
commit625cd5bcb315154ed28061fefaf639aff54da7c2 (patch)
tree1565bba217e20110aaccd4abedfdcea90ddd534d /django/apps/config.py
parentfd748c42a96213ebc0a18cc661ecb1abaadabcca (diff)
Added require_ready argument to get_model methods.
This allows bringing back the behavior of Django < 1.7. Also fixed the check for the app registry being ready in AppConfig.get_model(s), which was inconsistent with the equivalent check in Apps.get_model(s). That part is a backwards-incompatible change.
Diffstat (limited to 'django/apps/config.py')
-rw-r--r--django/apps/config.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/apps/config.py b/django/apps/config.py
index 72c5121411..14925cd1ce 100644
--- a/django/apps/config.py
+++ b/django/apps/config.py
@@ -155,13 +155,16 @@ class AppConfig(object):
# Entry is a path to an app config class.
return cls(app_name, app_module)
- def get_model(self, model_name):
+ def get_model(self, model_name, require_ready=True):
"""
Returns the model with the given case-insensitive model_name.
Raises LookupError if no model exists with this name.
"""
- self.apps.check_models_ready()
+ if require_ready:
+ self.apps.check_models_ready()
+ else:
+ self.apps.check_apps_ready()
try:
return self.models[model_name.lower()]
except KeyError: