【发布时间】:2018-06-16 04:22:15
【问题描述】:
根据 Django 频道文档,
You get access to a user’s normal Django session using the http_session
decorator - that gives you a message.http_session attribute that behaves
just like request.session. You can go one further and use
http_session_user which will provide a message.user attribute as well as
the session attribute.
无论如何我可以像这样设置会话变量吗?
我确实尝试过,但我收到一条错误消息,提示 NoneType is not iterable。
if 'username' not in message.http_session:
message.http_session['username'] = 'temp'
换句话说,message.http_session 返回一个 NoneType。我尝试过使用装饰器 @http_session 和 @channel_session_user_from_http,但它们也没有帮助。
【问题讨论】:
-
...是吗?你试过了吗?
-
你找到解决办法了吗?
标签: python django session channel django-channels