Opened 2 months ago
Closed 11 days ago
#36776 closed Cleanup/optimization (fixed)
Note that the dev server is running in WSGI mode
| Reported by: | Matthew Pava | Owned by: | jaffar Khan |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | jaffar Khan | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| 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 (13)
comment:1 by , 2 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:2 by , 2 months ago
| Component: | Documentation → Core (Management commands) |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| Version: | 6.0 → dev |
comment:3 by , 2 months 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 months ago
| Patch needs improvement: | set |
|---|
comment:6 by , 7 weeks ago
| Has patch: | set |
|---|
comment:7 by , 7 weeks ago
| Has patch: | unset |
|---|
comment:8 by , 2 weeks ago
Hi, I’d like to work on this by adding a documentation note about the
development server running in WSGI (sync) mode, as suggested above.
comment:9 by , 11 days ago
| Cc: | added |
|---|---|
| Has patch: | set |
I created a PR on this Issue: https://github.com/django/django/pull/20588
comment:10 by , 11 days ago
| Owner: | changed from to |
|---|
comment:11 by , 11 days ago
| Patch needs improvement: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
comment:12 by , 11 days ago
On second look I'm less convinced of the need to add anything in the middlewares section. If you're expecting async requests, you're using an async development server (perhaps the one from Daphne).
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.