Opened 3 weeks ago
Last modified 6 days ago
#36776 assigned Cleanup/optimization
Note that the dev server is running in WSGI mode
| Reported by: | Matthew Pava | Owned by: | Parvez Khan |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | yes | UI/UX: | no |
Description
With the mass adoption of async Django on the way, we need to provide a clearer warning in the development server that it is running in WSGI mode and not ASGI mode. I spent an hour troubleshooting a warning because I created a middleware that was async only. Only when I made it compatible for both async and sync modes did the warning go away.
Or we could just make the Django dev server default to ASGI mode.
Actual result:
The Django server displays this warning:
WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead.
For more information on production servers see: https://docs.djangoproject.com/en/6.0/howto/deployment/
Desired result:
Revise it to something like:
WARNING: This is a development server that is running only in sync mode (WSGI). Only middleware that is compatible with sync mode (WSGI) will run properly. Do not use it in a production setting. Use a production WSGI or ASGI server instead.
Change History (7)
comment:1 by , 3 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:2 by , 2 weeks ago
| Component: | Documentation → Core (Management commands) |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| Version: | 6.0 → dev |
comment:3 by , 2 weeks ago
That's fine. Can we also update the middleware documentation with some note that the development server only supports sync middleware?
https://docs.djangoproject.com/en/6.0/topics/http/middleware/
comment:5 by , 2 weeks ago
| Patch needs improvement: | set |
|---|
comment:6 by , 6 days ago
| Has patch: | set |
|---|
comment:7 by , 6 days ago
| Has patch: | unset |
|---|
In general, this seems fine to tweak. I checked Daphne's
runserveroutput, and it looks like:So I'd be happy to change Django's to:
django/core/management/commands/runserver.py
development server at {self.protocol}://{addr}:{server_port}/\n"However, mixing this information up with the security warning doesn't seem appropriate to me, nor taking a detour into middleware.