summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-01-06 22:57:56 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-01-06 23:01:29 +0100
commit2dcde523abe6dca42d9b2d46a47c402979974c77 (patch)
treef4f61e2020983fd20846b8341f0d5f09a5525510
parent6a320cc14ae6cd2606cc10a5ba8b1c09f737bab4 (diff)
Avoided catching ImproperlyConfigured on django.setup().
Fixed #21737. Thanks Florian for the report. Also removed redundant imports in that file.
-rw-r--r--django/core/management/__init__.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 34597bfa5f..6d0cb7ea3d 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -261,7 +261,6 @@ class ManagementUtility(object):
usage.append(" %s" % name)
# Output an extra note if settings are not properly configured
try:
- from django.conf import settings
settings.INSTALLED_APPS
except ImproperlyConfigured as e:
usage.append(style.NOTICE(
@@ -343,7 +342,6 @@ class ManagementUtility(object):
elif cwords[0] in ('dumpdata', 'sql', 'sqlall', 'sqlclear',
'sqlcustom', 'sqlindexes', 'sqlsequencereset', 'test'):
try:
- from django.apps import apps
app_configs = apps.get_app_configs()
# Get the last part of the dotted path as the app name.
options += [(app_config.label, 0) for app_config in app_configs]
@@ -386,10 +384,12 @@ class ManagementUtility(object):
pass # Ignore any option errors at this point.
try:
- django.setup()
+ settings.INSTALLED_APPS
except ImproperlyConfigured:
# Some commands are supposed to work without configured settings
pass
+ else:
+ django.setup()
try:
subcommand = self.argv[1]