From ed4264c5a44f01a626114e82240c977889e4a972 Mon Sep 17 00:00:00 2001 From: Jeroen van Veen Date: Tue, 22 Nov 2016 11:48:25 +0100 Subject: [PATCH] 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. --- django/core/management/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 7b667e7c8f..fdc1af2aa2 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -326,6 +326,15 @@ class ManagementUtility(object): apps.app_configs = OrderedDict() 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. else: django.setup()