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()