summaryrefslogtreecommitdiff
path: root/django/db/models/loading.py
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-07-29 21:04:41 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-07-29 21:04:41 +0000
commit9e957485bd99f0c4de457201f621fab7b63ad784 (patch)
treee83ec2c18d646449145076e8dce825940487f726 /django/db/models/loading.py
parent1a3b11261069490c534fd7487503ddc526680244 (diff)
Seed the global app cache in a call to db.models.get_model() except when we are
constructing a model class. Refs #2348. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3490 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/loading.py')
-rw-r--r--django/db/models/loading.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/db/models/loading.py b/django/db/models/loading.py
index c7920fa4e0..ece41ed6e4 100644
--- a/django/db/models/loading.py
+++ b/django/db/models/loading.py
@@ -75,11 +75,15 @@ def get_models(app_mod=None):
model_list.extend(get_models(app_mod))
return model_list
-def get_model(app_label, model_name):
+def get_model(app_label, model_name, seed_cache = True):
"""
- Returns the model matching the given app_label and case-insensitive model_name.
+ Returns the model matching the given app_label and case-insensitive
+ model_name.
+
Returns None if no model is found.
"""
+ if seed_cache:
+ get_apps()
try:
model_dict = _app_models[app_label]
except KeyError: