I am trying to implement a chat with Django and channels according to this tutorial (http://channels.readthedocs.io/en/latest/tutorial/part_2.html). I add channels and a chat app to installed apps. I make the following routings for a project:
# mysite/routing.py
from channels.routing import ProtocolTypeRouter
application = ProtocolTypeRouter({
# (http->django views is added by default)
})
Basically, I did exactly the steps from the tutorial. But after runserver
I am still getting ValueError: No application configured for scope type 'websocket'
, after going to a specific chat room. Can please someone help me?
You appear to be missing the websocket
key. The tutorial says to add following imports and add the websocket
key in mysite/routing.py
.
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
import chat.routing
application = ProtocolTypeRouter({
# (http->django views is added by default)
'websocket': AuthMiddlewareStack(
URLRouter(
chat.routing.websocket_urlpatterns
)
),
})
来源:https://stackoverflow.com/questions/49283575/django-channels-no-application-configured-for-scope-type-websocket