From 863bd3d36aac3d7e6456e79f7eaa338214705c6c Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 25 Feb 2006 19:35:30 +0000 Subject: [PATCH] magic-removal: Changed db.models.loading to make sure get_models() and get_model() both call get_apps() first to ensure _app_list cache is filled git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2394 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/loading.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django/db/models/loading.py b/django/db/models/loading.py index 5bd7909353..5c5b2e6c9c 100644 --- a/django/db/models/loading.py +++ b/django/db/models/loading.py @@ -34,11 +34,12 @@ def get_models(app_mod=None): Given a module containing models, returns a list of the models. Otherwise returns a list of all installed models. """ + app_list = get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. if app_mod: return _app_models.get(app_mod.__name__.split('.')[-2], {}).values() else: model_list = [] - for app_mod in get_apps(): + for app_mod in app_list: model_list.extend(get_models(app_mod)) return model_list @@ -47,6 +48,7 @@ def get_model(app_label, model_name): Returns the model matching the given app_label and case-insensitive model_name. Returns None if no model is found. """ + get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. try: model_dict = _app_models[app_label] except KeyError: