美文网首页
Python Django channel 中的Websocke

Python Django channel 中的Websocke

作者: Joncc | 来源:发表于2021-02-02 15:53 被阅读0次

报错:
Exception inside application: object.init() takes exactly one argument (the instance to initialize)

在routing.py中,使用python 3.6后的版本需要“ as_asgi()”。

if float(platform.python_version()[0:3]) > 3.6:
    cons = consumers.myConsumer.as_asgi()
else:
    cons = consumers.myConsumer

websocket_urlpatterns = [
    path("ws/example/", cons),
]

相关文章

网友评论

      本文标题:Python Django channel 中的Websocke

      本文链接:https://www.haomeiwen.com/subject/qkuytltx.html