Installed Django channels and Daphne

This commit is contained in:
Keannu Bernasol 2023-07-01 11:40:49 +08:00
parent e02d81f6fd
commit 88d838c5d8
2 changed files with 12 additions and 10 deletions

View file

@ -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.)
})

View file

@ -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',