Django渠道'未为范围类型'websocket配置任何应用程序' [英] Django channels 'No application configured for scope type 'websocket''
问题描述
我正在根据本教程( http://channels.readthedocs.io/en/latest/tutorial/part_2.html )。我将频道和聊天应用程序添加到已安装的应用程序中。我为项目进行以下路由:
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)
})
基本上,我完全按照教程中的步骤进行操作。但是在 runserver
之后,我仍然得到 ValueError:在转到特定位置后,没有为范围类型'websocket'
配置任何应用程序聊天室。
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?
推荐答案
您似乎缺少了 websocket
键。 教程表示要添加以下导入并在 mysite / routing.py
中添加 websocket
键。
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
)
),
})
这篇关于Django渠道'未为范围类型'websocket配置任何应用程序'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!