Avoided catching ImproperlyConfigured on django.setup().
Fixed #21737. Thanks Florian for the report. Also removed redundant imports in that file.
This commit is contained in:
parent
6a320cc14a
commit
2dcde523ab
|
@ -261,7 +261,6 @@ class ManagementUtility(object):
|
||||||
usage.append(" %s" % name)
|
usage.append(" %s" % name)
|
||||||
# Output an extra note if settings are not properly configured
|
# Output an extra note if settings are not properly configured
|
||||||
try:
|
try:
|
||||||
from django.conf import settings
|
|
||||||
settings.INSTALLED_APPS
|
settings.INSTALLED_APPS
|
||||||
except ImproperlyConfigured as e:
|
except ImproperlyConfigured as e:
|
||||||
usage.append(style.NOTICE(
|
usage.append(style.NOTICE(
|
||||||
|
@ -343,7 +342,6 @@ class ManagementUtility(object):
|
||||||
elif cwords[0] in ('dumpdata', 'sql', 'sqlall', 'sqlclear',
|
elif cwords[0] in ('dumpdata', 'sql', 'sqlall', 'sqlclear',
|
||||||
'sqlcustom', 'sqlindexes', 'sqlsequencereset', 'test'):
|
'sqlcustom', 'sqlindexes', 'sqlsequencereset', 'test'):
|
||||||
try:
|
try:
|
||||||
from django.apps import apps
|
|
||||||
app_configs = apps.get_app_configs()
|
app_configs = apps.get_app_configs()
|
||||||
# Get the last part of the dotted path as the app name.
|
# Get the last part of the dotted path as the app name.
|
||||||
options += [(app_config.label, 0) for app_config in app_configs]
|
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.
|
pass # Ignore any option errors at this point.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
django.setup()
|
settings.INSTALLED_APPS
|
||||||
except ImproperlyConfigured:
|
except ImproperlyConfigured:
|
||||||
# Some commands are supposed to work without configured settings
|
# Some commands are supposed to work without configured settings
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
django.setup()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subcommand = self.argv[1]
|
subcommand = self.argv[1]
|
||||||
|
|
Loading…
Reference in New Issue