Commit 24ebf17f authored by Aymeric Augustin's avatar Aymeric Augustin Committed by Tim Graham
Browse files

[1.9.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
parent f0a4ff2b
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
from __future__ import unicode_literals

import collections
import os
import pkgutil
import sys
from collections import OrderedDict, defaultdict
from importlib import import_module

import django
@@ -144,7 +144,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'
@@ -316,8 +316,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:
+5 −0
Original line number Diff line number Diff line
@@ -53,3 +53,8 @@ Bugfixes

* Fixed a regression which prevented using a language not in Django's default
  language list (:setting:`LANGUAGES`) (:ticket:`25915`).

* Avoided hiding some exceptions, like an invalid ``INSTALLED_APPS`` setting,
  behind ``AppRegistryNotReady`` when starting ``runserver`` (:ticket:`25510`).
  This regression appeared in 1.8.5 as a side effect of fixing :ticket:`24704`
  and by mistake the fix wasn't applied to the ``stable/1.9.x`` branch.