Opened 9 years ago
Closed 9 years ago
#27522 closed Bug (fixed)
./manage runserver --nostatic doesn't return a traceback
| Reported by: | Jeroen van Veen | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | runserver nostatic |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When running ./manage runserver --nostatic, I expect a traceback to be returned when
a syntax error occurs, and I expect the autoreloader still to be available. Instead, the
runserver command exits like:
usage: manage.py runserver [-h] [--version] [-v {0,1,2,3}]
[--settings SETTINGS] [--pythonpath PYTHONPATH]
[--traceback] [--no-color] [--ipv6] [--nothreading]
[--noreload]
[addrport]
manage.py runserver: error: unrecognized arguments: --nostatic
Ticket: https://github.com/wearespindle/django/tree/ticket_27522
Change History (13)
comment:2 by , 9 years ago
| Description: | modified (diff) |
|---|
comment:4 by , 9 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:5 by , 9 years ago
| Version: | 1.10 → 1.8 |
|---|
comment:6 by , 9 years ago
| Keywords: | runserver nostatic added |
|---|
comment:7 by , 9 years ago
| Description: | modified (diff) |
|---|---|
| Version: | 1.8 → master |
comment:8 by , 9 years ago
I can reproduce the problem. Without taking a closer look, I'm not sure about the solution. If you could write a test, that would certainly help.
comment:9 by , 9 years ago
| Description: | modified (diff) |
|---|---|
| Has patch: | set |
| Needs tests: | set |
PR (currently without tests)
comment:10 by , 9 years ago
| Description: | modified (diff) |
|---|---|
| Needs tests: | unset |
I'm trying to figure out where this test should be placed.
comment:11 by , 9 years ago
| Needs tests: | set |
|---|
Some tests for runserver are in admin_scripts/tests.py. It might be infeasible to test this (for example, fe6ddb837d18bd4e71cd22fc18272d31478b19f2 lacked tests) but it would be nice to try.
comment:13 by , 9 years ago
| Needs tests: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Steps to reproduce: modify a Django project to have a syntax error and run runserver --nostatic. You should see the SyntaxError traceback (after this fix) rather than manage.py runserver: error: unrecognized arguments: --nostatic.
I don't think it's feasible to write a test for this so I'll commit the change without one.
This is a workaround:
--- django/core/management/__init__.py.orig 2016-11-22 09:58:38.806209538 +0100 +++ django/core/management/__init__.py 2016-11-22 10:10:00.229652313 +0100 @@ -323,6 +323,10 @@ apps.all_models = defaultdict(OrderedDict) apps.app_configs = OrderedDict() apps.apps_ready = apps.models_ready = apps.ready = True + # Execute the runserver command, but strip off additional + # parameters that cause the argument parser to fail. + self.fetch_command(subcommand).run_from_argv(self.argv[0:2]) + return # In all other cases, django.setup() is required to succeed. else: