diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-31 13:09:47 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-31 13:11:05 +0100 |
| commit | 6b172a6d6dcfe88be4dc0e5052707a756c1c830c (patch) | |
| tree | 2b4fab9d3b97854fdedb4d317fcf981dfea9c916 | |
| parent | 1fb873cd6bb1867b71151bcf0c84ba8ebd205326 (diff) | |
Called django.setup() explicitly in management commands.
This avoids duplicating code.
| -rw-r--r-- | django/core/management/__init__.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 2a4fd96fc7..fcd7c7ccd8 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -5,6 +5,7 @@ from optparse import OptionParser, NO_DEFAULT import os import sys +import django from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.management.base import BaseCommand, CommandError, handle_default_options @@ -111,17 +112,16 @@ def get_commands(): # Find the installed apps try: - installed_apps = settings.INSTALLED_APPS + settings.INSTALLED_APPS except ImproperlyConfigured: # Still useful for commands that do not require functional # settings, like startproject or help. app_names = [] else: - # Populate the app registry outside of the try/except block to - # avoid catching ImproperlyConfigured errors that aren't caused - # by the absence of a settings module. - from django.apps import apps - apps.populate(installed_apps) + # Setup Django outside of the try/except block to avoid catching + # ImproperlyConfigured errors that aren't caused by the absence of + # a settings module. + django.setup() app_configs = apps.get_app_configs() app_names = [app_config.name for app_config in app_configs] |
