summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-09-29 15:05:23 +0200
committerClaude Paroz <claude@2xlibre.net>2016-09-30 17:25:28 +0200
commitfc92c6b5000179145ec633a70f380a0a109381c3 (patch)
tree0a27bda2116438553908719d3986d1a7a3f06a94
parent79c91070e5797f647347c2f8bdfc4c7a0f835fb3 (diff)
Removed unneeded no_settings_commands hardcoded list
Thanks Tim Graham for the review.
-rw-r--r--django/core/management/__init__.py9
-rw-r--r--django/core/management/base.py7
-rw-r--r--django/core/management/templates.py3
3 files changed, 8 insertions, 11 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index a49ffdd3b8..7b667e7c8f 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -306,19 +306,10 @@ class ManagementUtility(object):
except CommandError:
pass # Ignore any option errors at this point.
- no_settings_commands = [
- 'help', 'version', '--help', '--version', '-h',
- 'startapp', 'startproject', 'compilemessages',
- ]
-
try:
settings.INSTALLED_APPS
except ImproperlyConfigured as 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:
# Start the auto-reloading dev server even if the code is broken.
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 3726d42150..6aaf2fc4bb 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -303,7 +303,12 @@ class BaseCommand(object):
self.stderr.write('%s: %s' % (e.__class__.__name__, e))
sys.exit(1)
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):
"""
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index fd957fbabf..466ea935d8 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -11,6 +11,7 @@ import tempfile
from os import path
import django
+from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import handle_extensions
from django.template import Context, Engine
@@ -119,9 +120,9 @@ class TemplateCommand(BaseCommand):
}), autoescape=False)
# Setup a stub settings environment for template rendering
- from django.conf import settings
if not settings.configured:
settings.configure()
+ django.setup()
template_dir = self.handle_template(options['template'],
base_subdir)