Skip to content

Commit

Permalink
Avoided catching ImproperlyConfigured on django.setup().
Browse files Browse the repository at this point in the history
Fixed #21737. Thanks Florian for the report.

Also removed redundant imports in that file.
  • Loading branch information
aaugustin committed Jan 6, 2014
1 parent 6a320cc commit 2dcde52
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions django/core/management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def main_help_text(self, commands_only=False):
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(
Expand Down Expand Up @@ -343,7 +342,6 @@ def autocomplete(self):
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]
Expand Down Expand Up @@ -386,10 +384,12 @@ def execute(self):
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]
Expand Down

0 comments on commit 2dcde52

Please sign in to comment.