Loading django/contrib/staticfiles/finders.py +4 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ from collections import OrderedDict import os from django.conf import settings from django.core.apps import app_cache from django.core.exceptions import ImproperlyConfigured from django.core.files.storage import default_storage, Storage, FileSystemStorage from django.utils.functional import empty, LazyObject Loading Loading @@ -116,10 +117,11 @@ class AppDirectoriesFinder(BaseFinder): def __init__(self, apps=None, *args, **kwargs): # The list of apps that are handled self.apps = [] # Mapping of app module paths to storage instances # Mapping of app names to storage instances self.storages = OrderedDict() if apps is None: apps = settings.INSTALLED_APPS app_configs = app_cache.get_app_configs() apps = [app_config.name for app_config in app_configs] for app in apps: app_storage = self.storage_class(app) if os.path.isdir(app_storage.location): Loading django/core/management/__init__.py +14 −6 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from optparse import OptionParser, NO_DEFAULT import os import sys from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.management.base import BaseCommand, CommandError, handle_default_options from django.core.management.color import color_style Loading Loading @@ -106,13 +107,19 @@ def get_commands(): _commands = dict((name, 'django.core') for name in find_commands(__path__[0])) # Find the installed apps from django.conf import settings try: apps = settings.INSTALLED_APPS settings.INSTALLED_APPS except ImproperlyConfigured: # Still useful for commands that do not require functional settings, # like startproject or help # Still useful for commands that do not require functional # settings, like startproject or help. apps = [] else: # Populate the app cache outside of the try/except block to avoid # catching ImproperlyConfigured errors that aren't caused by the # absence of a settings module. from django.core.apps import app_cache app_configs = app_cache.get_app_configs() apps = [app_config.name for app_config in app_configs] # Find and load the management module for each installed app. for app_name in apps: Loading Loading @@ -339,9 +346,10 @@ class ManagementUtility(object): elif cwords[0] in ('dumpdata', 'sql', 'sqlall', 'sqlclear', 'sqlcustom', 'sqlindexes', 'sqlsequencereset', 'test'): try: from django.conf import settings from django.core.apps import app_cache app_configs = app_cache.get_app_configs() # Get the last part of the dotted path as the app name. options += [(a.split('.')[-1], 0) for a in settings.INSTALLED_APPS] options += [(app_config.label, 0) for app_config in app_configs] except ImportError: # Fail silently if DJANGO_SETTINGS_MODULE isn't set. The # user will find out once they execute the command. Loading django/core/management/commands/flush.py +2 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import sys from importlib import import_module from optparse import make_option from django.conf import settings from django.core.apps import app_cache from django.db import connections, router, transaction, DEFAULT_DB_ALIAS from django.core.management import call_command Loading Loading @@ -42,9 +41,9 @@ class Command(NoArgsCommand): # Import the 'management' module within each installed app, to register # dispatcher events. for app_name in settings.INSTALLED_APPS: for app_config in app_cache.get_app_configs(): try: import_module('.management', app_name) import_module('.management', app_config.name) except ImportError: pass Loading django/core/management/commands/migrate.py +3 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ from importlib import import_module import itertools import traceback from django.conf import settings from django.core.apps import app_cache from django.core.management import call_command from django.core.management.base import BaseCommand, CommandError Loading Loading @@ -47,9 +46,9 @@ class Command(BaseCommand): # Import the 'management' module within each installed app, to register # dispatcher events. for app_name in settings.INSTALLED_APPS: if module_has_submodule(import_module(app_name), "management"): import_module('.management', app_name) for app_config in app_cache.get_app_configs(): if module_has_submodule(app_config.app_module, "management"): import_module('.management', app_config.name) # Get the database we're operating from db = options.get('database') Loading django/template/base.py +6 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from importlib import import_module from inspect import getargspec, getcallargs from django.conf import settings from django.core.apps import app_cache from django.template.context import (BaseContext, Context, RequestContext, # NOQA: imported for backwards compatibility ContextPopException) from django.utils.itercompat import is_iterable Loading Loading @@ -1302,9 +1303,12 @@ def get_templatetags_modules(): # Populate list once per process. Mutate the local list first, and # then assign it to the global name to ensure there are no cases where # two threads try to populate it simultaneously. for app_module in ['django'] + list(settings.INSTALLED_APPS): templatetags_modules_candidates = ['django.templatetags'] templatetags_modules_candidates += ['%s.templatetags' % app_config.name for app_config in app_cache.get_app_configs()] for templatetag_module in templatetags_modules_candidates: try: templatetag_module = '%s.templatetags' % app_module import_module(templatetag_module) _templatetags_modules.append(templatetag_module) except ImportError: Loading Loading
django/contrib/staticfiles/finders.py +4 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ from collections import OrderedDict import os from django.conf import settings from django.core.apps import app_cache from django.core.exceptions import ImproperlyConfigured from django.core.files.storage import default_storage, Storage, FileSystemStorage from django.utils.functional import empty, LazyObject Loading Loading @@ -116,10 +117,11 @@ class AppDirectoriesFinder(BaseFinder): def __init__(self, apps=None, *args, **kwargs): # The list of apps that are handled self.apps = [] # Mapping of app module paths to storage instances # Mapping of app names to storage instances self.storages = OrderedDict() if apps is None: apps = settings.INSTALLED_APPS app_configs = app_cache.get_app_configs() apps = [app_config.name for app_config in app_configs] for app in apps: app_storage = self.storage_class(app) if os.path.isdir(app_storage.location): Loading
django/core/management/__init__.py +14 −6 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from optparse import OptionParser, NO_DEFAULT import os import sys from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.management.base import BaseCommand, CommandError, handle_default_options from django.core.management.color import color_style Loading Loading @@ -106,13 +107,19 @@ def get_commands(): _commands = dict((name, 'django.core') for name in find_commands(__path__[0])) # Find the installed apps from django.conf import settings try: apps = settings.INSTALLED_APPS settings.INSTALLED_APPS except ImproperlyConfigured: # Still useful for commands that do not require functional settings, # like startproject or help # Still useful for commands that do not require functional # settings, like startproject or help. apps = [] else: # Populate the app cache outside of the try/except block to avoid # catching ImproperlyConfigured errors that aren't caused by the # absence of a settings module. from django.core.apps import app_cache app_configs = app_cache.get_app_configs() apps = [app_config.name for app_config in app_configs] # Find and load the management module for each installed app. for app_name in apps: Loading Loading @@ -339,9 +346,10 @@ class ManagementUtility(object): elif cwords[0] in ('dumpdata', 'sql', 'sqlall', 'sqlclear', 'sqlcustom', 'sqlindexes', 'sqlsequencereset', 'test'): try: from django.conf import settings from django.core.apps import app_cache app_configs = app_cache.get_app_configs() # Get the last part of the dotted path as the app name. options += [(a.split('.')[-1], 0) for a in settings.INSTALLED_APPS] options += [(app_config.label, 0) for app_config in app_configs] except ImportError: # Fail silently if DJANGO_SETTINGS_MODULE isn't set. The # user will find out once they execute the command. Loading
django/core/management/commands/flush.py +2 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import sys from importlib import import_module from optparse import make_option from django.conf import settings from django.core.apps import app_cache from django.db import connections, router, transaction, DEFAULT_DB_ALIAS from django.core.management import call_command Loading Loading @@ -42,9 +41,9 @@ class Command(NoArgsCommand): # Import the 'management' module within each installed app, to register # dispatcher events. for app_name in settings.INSTALLED_APPS: for app_config in app_cache.get_app_configs(): try: import_module('.management', app_name) import_module('.management', app_config.name) except ImportError: pass Loading
django/core/management/commands/migrate.py +3 −4 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ from importlib import import_module import itertools import traceback from django.conf import settings from django.core.apps import app_cache from django.core.management import call_command from django.core.management.base import BaseCommand, CommandError Loading Loading @@ -47,9 +46,9 @@ class Command(BaseCommand): # Import the 'management' module within each installed app, to register # dispatcher events. for app_name in settings.INSTALLED_APPS: if module_has_submodule(import_module(app_name), "management"): import_module('.management', app_name) for app_config in app_cache.get_app_configs(): if module_has_submodule(app_config.app_module, "management"): import_module('.management', app_config.name) # Get the database we're operating from db = options.get('database') Loading
django/template/base.py +6 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from importlib import import_module from inspect import getargspec, getcallargs from django.conf import settings from django.core.apps import app_cache from django.template.context import (BaseContext, Context, RequestContext, # NOQA: imported for backwards compatibility ContextPopException) from django.utils.itercompat import is_iterable Loading Loading @@ -1302,9 +1303,12 @@ def get_templatetags_modules(): # Populate list once per process. Mutate the local list first, and # then assign it to the global name to ensure there are no cases where # two threads try to populate it simultaneously. for app_module in ['django'] + list(settings.INSTALLED_APPS): templatetags_modules_candidates = ['django.templatetags'] templatetags_modules_candidates += ['%s.templatetags' % app_config.name for app_config in app_cache.get_app_configs()] for templatetag_module in templatetags_modules_candidates: try: templatetag_module = '%s.templatetags' % app_module import_module(templatetag_module) _templatetags_modules.append(templatetag_module) except ImportError: Loading