Python Django channel 中的Websocke

2021-02-02  本文已影响0人  Joncc

报错:
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),
]
上一篇 下一篇

猜你喜欢

热点阅读