summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgeekodour <hrishikeshbman@gmail.com>2017-11-20 12:32:14 +0530
committerTim Graham <timograham@gmail.com>2017-12-07 14:19:18 -0500
commitc6864a01b25591d3a709da8071413b69c9e35341 (patch)
tree0828a224d6ddc7221faff9b43592fd730b759191
parent16bd4964dfd75759cb3ec0c786e1b5dcc8296fd9 (diff)
Fixed #28791 -- Allowed commands that don't require settings to work if the DJANGO_SETTINGS_MODULE doesn't exist.
-rw-r--r--django/core/management/__init__.py2
-rw-r--r--tests/admin_scripts/tests.py10
2 files changed, 12 insertions, 0 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index d6395e0a03..2500d0b70e 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -317,6 +317,8 @@ class ManagementUtility:
settings.INSTALLED_APPS
except ImproperlyConfigured as exc:
self.settings_exception = exc
+ except ImportError as exc:
+ self.settings_exception = exc
if settings.configured:
# Start the auto-reloading dev server even if the code is broken.
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index e56d43c4bc..1670af86fb 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -236,6 +236,16 @@ class DjangoAdminNoSettings(AdminScriptTestCase):
self.assertNoOutput(out)
self.assertOutput(err, "No module named '?bad_settings'?", regex=True)
+ def test_commands_with_invalid_settings(self):
+ """"
+ Commands that don't require settings succeed if the settings file
+ doesn't exist.
+ """
+ args = ['startproject']
+ out, err = self.run_django_admin(args, settings_file='bad_settings')
+ self.assertNoOutput(out)
+ self.assertOutput(err, "You must provide a project name", regex=True)
+
class DjangoAdminDefaultSettings(AdminScriptTestCase):
"""A series of tests for django-admin.py when using a settings.py file that