Django channels 'No application configured for scope type 'websocket''

后端 未结 1 1778
忘掉有多难
忘掉有多难 2021-01-21 20:20

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 ap

1条回答
  •  温柔的废话
    2021-01-21 20:55

    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
            )
        ),
    })
    

    0 讨论(0)
提交回复
热议问题