我正在使用 django-channels 进行聊天应用程序,但我遇到了奇怪的路由错误。
AttributeError: 'Message' object has no attribute 'META'
所以这是我的routing.py
from channels.routing import route, include
from chat.consumers import ws_connect, ws_message, ws_disconnect
from chat.views import chatmain
http_routing = [
route("http.request", chatmain, path=r"^/chatwindow/$", method=r"^GET$"),
]
chat_routing = [
route("websocket.connect", ws_connect),
route("websocket.receive", ws_message),
route("websocket.disconnect", ws_disconnect),
]
channel_routing = [
include(chat_routing),
include(http_routing),
]
然后我想按照 /chatwindow 链接使用普通视图并卸载聊天应用程序,但它不起作用。