summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2015-10-15 22:03:25 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2015-10-19 20:41:48 +0200
commit9ccb92ad0130c0fc5fec43d3b914b49df688ffa5 (patch)
tree0fcec6075b02030999788076ad9864541e3bf893
parent61ea3718224e6264f2d21858da70e3cbff3bd72e (diff)
downloaddjango-9ccb92ad0130c0fc5fec43d3b914b49df688ffa5.tar.gz
[1.8.x] Fixed #25510 -- Allowed runserver to start with incorrect INSTALLED_APPS.
In that case, the content of INSTALLED_APPS will be ignored until it's fixed and the autoreloader kicks in. I confirmed this behavior manually. As explained on the ticket it's hard to write a test for this case Backport of df0a446f from master.
-rw-r--r--django/core/management/__init__.py11
-rw-r--r--docs/releases/1.8.6.txt4
2 files changed, 11 insertions, 4 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index e2885bbd2a..4bbf57e175 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-import collections
+from collections import OrderedDict, defaultdict
from importlib import import_module
import os
import pkgutil
@@ -145,7 +145,7 @@ class ManagementUtility(object):
"",
"Available subcommands:",
]
- commands_dict = collections.defaultdict(lambda: [])
+ commands_dict = defaultdict(lambda: [])
for name, app in six.iteritems(get_commands()):
if app == 'django.core':
app = 'django'
@@ -317,8 +317,11 @@ class ManagementUtility(object):
autoreload.check_errors(django.setup)()
except Exception:
# The exception will be raised later in the child process
- # started by the autoreloader.
- pass
+ # started by the autoreloader. Pretend it didn't happen by
+ # loading an empty list of applications.
+ apps.all_models = defaultdict(OrderedDict)
+ apps.app_configs = OrderedDict()
+ apps.apps_ready = apps.models_ready = apps.ready = True
# In all other cases, django.setup() is required to succeed.
else:
diff --git a/docs/releases/1.8.6.txt b/docs/releases/1.8.6.txt
index 178d714f01..8fb9e16be5 100644
--- a/docs/releases/1.8.6.txt
+++ b/docs/releases/1.8.6.txt
@@ -25,3 +25,7 @@ Bugfixes
* Allowed filtering over a ``RawSQL`` annotation (:ticket:`25506`).
* Made the ``Concat`` database function idempotent on SQLite (:ticket:`25517`).
+
+* Avoided a confusing stack trace when starting :djadmin:`runserver` with an
+ invalid :setting:`INSTALLED_APPS` setting (:ticket:`25510`). This regression
+ appeared in 1.8.5 as a side effect of fixing :ticket:`24704`.