Removed unneeded no_settings_commands hardcoded list
Thanks Tim Graham for the review.
This commit is contained in:
parent
79c91070e5
commit
fc92c6b500
|
@ -306,19 +306,10 @@ class ManagementUtility(object):
|
||||||
except CommandError:
|
except CommandError:
|
||||||
pass # Ignore any option errors at this point.
|
pass # Ignore any option errors at this point.
|
||||||
|
|
||||||
no_settings_commands = [
|
|
||||||
'help', 'version', '--help', '--version', '-h',
|
|
||||||
'startapp', 'startproject', 'compilemessages',
|
|
||||||
]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
settings.INSTALLED_APPS
|
settings.INSTALLED_APPS
|
||||||
except ImproperlyConfigured as exc:
|
except ImproperlyConfigured as exc:
|
||||||
self.settings_exception = exc
|
self.settings_exception = exc
|
||||||
# A handful of built-in management commands work without settings.
|
|
||||||
# Load the default settings -- where INSTALLED_APPS is empty.
|
|
||||||
if subcommand in no_settings_commands:
|
|
||||||
settings.configure()
|
|
||||||
|
|
||||||
if settings.configured:
|
if settings.configured:
|
||||||
# Start the auto-reloading dev server even if the code is broken.
|
# Start the auto-reloading dev server even if the code is broken.
|
||||||
|
|
|
@ -303,7 +303,12 @@ class BaseCommand(object):
|
||||||
self.stderr.write('%s: %s' % (e.__class__.__name__, e))
|
self.stderr.write('%s: %s' % (e.__class__.__name__, e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
connections.close_all()
|
try:
|
||||||
|
connections.close_all()
|
||||||
|
except ImproperlyConfigured:
|
||||||
|
# Ignore if connections aren't setup at this point (e.g. no
|
||||||
|
# configured settings).
|
||||||
|
pass
|
||||||
|
|
||||||
def execute(self, *args, **options):
|
def execute(self, *args, **options):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -11,6 +11,7 @@ import tempfile
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
import django
|
import django
|
||||||
|
from django.conf import settings
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.core.management.utils import handle_extensions
|
from django.core.management.utils import handle_extensions
|
||||||
from django.template import Context, Engine
|
from django.template import Context, Engine
|
||||||
|
@ -119,9 +120,9 @@ class TemplateCommand(BaseCommand):
|
||||||
}), autoescape=False)
|
}), autoescape=False)
|
||||||
|
|
||||||
# Setup a stub settings environment for template rendering
|
# Setup a stub settings environment for template rendering
|
||||||
from django.conf import settings
|
|
||||||
if not settings.configured:
|
if not settings.configured:
|
||||||
settings.configure()
|
settings.configure()
|
||||||
|
django.setup()
|
||||||
|
|
||||||
template_dir = self.handle_template(options['template'],
|
template_dir = self.handle_template(options['template'],
|
||||||
base_subdir)
|
base_subdir)
|
||||||
|
|
Loading…
Reference in New Issue