diff --git a/stude/config/asgi.py b/stude/config/asgi.py index 1b71627..771a0e5 100644 --- a/stude/config/asgi.py +++ b/stude/config/asgi.py @@ -1,16 +1,14 @@ -""" -ASGI config for stude project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ -""" - import os +from channels.routing import ProtocolTypeRouter from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') +# Initialize Django ASGI application early to ensure the AppRegistry +# is populated before importing code that may import ORM models. +django_asgi_app = get_asgi_application() -application = get_asgi_application() +application = ProtocolTypeRouter({ + "http": django_asgi_app, + # Just HTTP for now. (We can add other protocols later.) +}) diff --git a/stude/config/settings.py b/stude/config/settings.py index 4a89979..1ce5de9 100644 --- a/stude/config/settings.py +++ b/stude/config/settings.py @@ -52,6 +52,8 @@ else: # Application definition INSTALLED_APPS = [ + 'daphne', + 'channels', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -88,6 +90,8 @@ STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" ROOT_URLCONF = 'config.urls' +ASGI_APPLICATION = "config.asgi.application" + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates',