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 Parvez Khan, 3 weeks ago

Owner: set to Parvez Khan
Status: newassigned

comment:2 by Jacob Walls, 2 weeks ago

Component: DocumentationCore (Management commands)
Triage Stage: UnreviewedAccepted
Version: 6.0dev

In general, this seems fine to tweak. I checked Daphne's runserver output, and it looks like:

Starting ASGI/Daphne version 4.2.1 development server at http://127.0.0.1:8000/

So I'd be happy to change Django's to:

  • django/core/management/commands/runserver.py

    diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
    index 0cf841b747..260badce5c 100644
    a b class Command(BaseCommand):  
    184184        print(
    185185            f"{now}\n"
    186186            f"Django version {version}, using settings {settings.SETTINGS_MODULE!r}\n"
    187             f"Starting development server at {self.protocol}://{addr}:{server_port}/\n"
     187            f"Starting WSGI development server at {self.protocol}://{addr}:{server_port}/\n"
    188188            f"Quit the server with {quit_command}.",
    189189            file=self.stdout,
    190190        )

However, mixing this information up with the security warning doesn't seem appropriate to me, nor taking a detour into middleware.

comment:3 by Matthew Pava, 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:4 by Jacob Walls, 2 weeks ago

Either there or on the async support page seems reasonable.

comment:5 by Clifford Gama, 2 weeks ago

Patch needs improvement: set

comment:6 by Nilesh Pahari, 6 days ago

Has patch: set

comment:7 by Nilesh Pahari, 6 days ago

Has patch: unset
Note: See TracTickets for help on using tickets.
Back to Top