/django-realtime-chat

A real-time messaging system using Django Channels.

Primary LanguagePythonMIT LicenseMIT

Django Real-Time Chat

A messaging system using Django and Django Channels written in Python.

Channels Setup

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. image01

Additional READMEs

Setup and configurations