A messaging system using Django and Django Channels written in Python.
Add channels to INSTALLED_APPS in settings.py
INSTALLED_APPS = [
...
"channels",
]Update project’s asgi.py to wrap the Django ASGI application:
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "realtime_chat.settings")
application = ProtocolTypeRouter(
{
"http": get_asgi_application(),
# Add other protocols later
}
)Add the asgi application using ASGI_APPLICATION in settings.py.
ASGI_APPLICATION = "realtime_chat.asgi.application"Once development server is run using the runserver command, the server would use the ASGI application object specified in ASGI_APPLICATION instead of the default WSGI application.