运行项目出现错误:
ImportError: cannot import name ‘DEFAULT_CHANNEL_LAYER’ from ‘channels’
我的django配置文件里是这样的
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("localhost", 6379)],
},
},
}
在manage.py中也有声明
os.environ['DJANGO_SETTINGS_MODULE'] = 'Web.settings'
最后:
pip uninstall asgi_redis
pip uninstall channels-redis
pip uninstall channels # Successfully uninstalled channels-2.1.5
pip install channels
# Successfully uninstalled daphne-2.2.3
# 安装信息中出现daphne~=2.3
#Found existing installation: daphne 2.2.3
# Uninstalling daphne-2.2.3:
# Successfully uninstalled daphne-2.2.3
#Successfully installed channels-2.2.0 daphne-2.3.0
最后执行runserver没有报错了, 也许是channels,daphne版本问题造成的