Fixed #27522 -- Fixed runserver autoreload when using staticfile's options.

On a SyntaxError, made runserver exit with a stacktrace when using
contrib.staticfiles's runserver options such as --nostatic.
This commit is contained in:
Jeroen van Veen 2016-11-22 11:48:25 +01:00 committed by Tim Graham
parent 6128c1736d
commit ed4264c5a4
1 changed files with 9 additions and 0 deletions

View File

@ -326,6 +326,15 @@ class ManagementUtility(object):
apps.app_configs = OrderedDict() apps.app_configs = OrderedDict()
apps.apps_ready = apps.models_ready = apps.ready = True apps.apps_ready = apps.models_ready = apps.ready = True
# Remove options not compatible with the built-in runserver
# (e.g. options for the contrib.staticfiles' runserver).
# Changes here require manually testing as described in
# #27522.
_parser = self.fetch_command('runserver').create_parser('django', 'runserver')
_options, _args = _parser.parse_known_args(self.argv[2:])
for _arg in _args:
self.argv.remove(_arg)
# In all other cases, django.setup() is required to succeed. # In all other cases, django.setup() is required to succeed.
else: else:
django.setup() django.setup()