WSGI vs ASGI (Django)
WSGI and ASGI are the interfaces between web servers and Django. WSGI is the long-standing synchronous standard; ASGI is the newer asynchronous one that adds support for async views, WebSockets, and long-lived connections.
Django
When you create a Django project it generates both wsgi.py and asgi.py — the entry points a server imports to run your app. WSGI (Web Server Gateway Interface) is synchronous: one request is handled at a time per worker, which suits typical request/response sites and is served by Gunicorn or uWSGI.
ASGI (Asynchronous Server Gateway Interface) extends the idea to async. It supports Django's async views, WebSockets, and Server-Sent Events — anything needing long-lived or concurrent connections — and is served by an ASGI server like Uvicorn or Daphne.
For a standard CRUD site, WSGI is simpler and entirely sufficient. Choose ASGI when you need real-time features (chat, live updates) or heavy async I/O. Django supports both, and you pick the server accordingly at deployment.
Syntax
gunicorn mysite.wsgi | uvicorn mysite.asgi:applicationExamples
Python
# mysite/wsgi.py (synchronous)
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# mysite/asgi.py (asynchronous)
from django.core.asgi import get_asgi_application
application = get_asgi_application()