1. ws/settings.py
INSTALLED_APPS = [
'channels', # add
'chat', # add
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
# WSGI_APPLICATION = 'ws.wsgi.application'
ASGI_APPLICATION = "ws.asgi.application" # add
Note
The Channels development server will conflict with any other third-party apps that require an overloaded or replacement runserver command. In order to solve such issues, try moving channels
to the top of your INSTALLED_APPS
or remove the offending app altogether.
2. ws/asgi.py
import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ws.settings')
application = ProtocolTypeRouter({
"http" : get_asgi_application(),
# Just HTTP for now. (We can add other protocols later.)
})
Change existing content of asgi.py
3. Start runserver
when runserver, if you see below error message
(.venv) C:\Work\Python project\ws.daonelab.com>python manage.py migrate
run above command and start again
then you can see, below message
Starting ASGI/Channels version 3.0.5 development server at http://127.0.0.1:8000/
instead of below message
Starting development server at http://127.0.0.1:8000/
without error message