diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-19 15:57:23 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-22 11:39:18 +0100 |
| commit | 65cd74be8e99d06c7861edc5050e34d6444e4d56 (patch) | |
| tree | 72431d2a70af3d235543781fadce8e647c746959 /django/utils/module_loading.py | |
| parent | d4733b6df07b1f8a869eed8eac86869d1d14472c (diff) | |
Stopped iterating on INSTALLED_APPS.
Used the app cache's get_app_configs() method instead.
Diffstat (limited to 'django/utils/module_loading.py')
| -rw-r--r-- | django/utils/module_loading.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py index 0c6bad2a7b..8d95fc00a3 100644 --- a/django/utils/module_loading.py +++ b/django/utils/module_loading.py @@ -58,18 +58,17 @@ def autodiscover_modules(*args, **kwargs): registry. This register_to object must have a _registry instance variable to access it. """ - from django.conf import settings + from django.core.apps import app_cache register_to = kwargs.get('register_to') - for app in settings.INSTALLED_APPS: - mod = import_module(app) + for app_config in app_cache.get_app_configs(): # Attempt to import the app's module. try: if register_to: before_import_registry = copy.copy(register_to._registry) for module_to_search in args: - import_module('%s.%s' % (app, module_to_search)) + import_module('%s.%s' % (app_config.name, module_to_search)) except: # Reset the model registry to the state before the last import as # this import will have to reoccur on the next request and this @@ -81,7 +80,7 @@ def autodiscover_modules(*args, **kwargs): # Decide whether to bubble up this error. If the app just # doesn't have an admin module, we can ignore the error # attempting to import it, otherwise we want it to bubble up. - if module_has_submodule(mod, module_to_search): + if module_has_submodule(app_config.app_module, module_to_search): raise |
