繁体   English   中英

如何解决错误:'tuple' object has no attribute 'decode' with django-channels

[英]How to solve the error: 'tuple' object has no attribute 'decode' with django-channels

当我尝试执行频道教程以使用 websocket 建立 django 网站时,出现错误消息:

AttributeError: 'tuple' object 没有属性 'decode'

我刚刚执行了以下代码:

$ python3 manage.py shell
>>> import channels.layers
>>> channel_layer = channels.layers.get_channel_layer()
>>> from asgiref.sync import async_to_sync
>>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})

教程链接: https://channels.readthedocs.io/en/stable/tutorial/part_2.html

环境:Ubuntu 20.04LTS 和 Python 3.8.10 django 4.1.3 channels 4.0.0 channels-redis 4.0.0 daphne 4.0.0 asgiref 3.5.2

我认为问题可能是asgiref引起的,但没有文档可供参考。

我有同样的错误,因为我遇到了这个问题,所以我降级到 channels_redis v 3.4.0,错误消失了。 等待更好的解决方案,我希望它会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM