我基本上是在django頻道的login_required/LoginRequiredMixin等效之後。該文檔有一個authentication section,它描述瞭如何獲得用戶,但它似乎錯過了實際上拒絕訪問未經身份驗證的用戶訪問的位置。 from channels.generic.websockets import JsonWebsocketConsumer
class MyConsu
從the docs,allowed_hosts_only是一個裝飾器,以確保連接起源在settings.ALLOWED_HOSTS。但是,我很難將其應用於基於類的消費者。該applying decorators部分解釋瞭如何裝飾添加到類: from channels.generic.websockets import JsonWebsocketConsumer
from channels.sec
我有數據發送到渠道這段JavaScript代碼 // Note that the path doesn't matter for routing; any WebSocket
// connection gets bumped over to WebSocket consumers
socket = new WebSocket("ws://" + window.location.host +