Django Channels Error - Cannot import BACKEND 'asgi_redis.RedisChannelLayer'

前端 未结 6 1076
面向向阳花
面向向阳花 2021-01-11 12:22

I have installed Django-Channels but while running the daphne-server I am getting this error given below:

File \"/usr/local/lib/python2.7/dist-packages/chann         


        
相关标签:
6条回答
  • 2021-01-11 12:54

    In my case asgiref version 2.3.2 was not compatible. I downgraded it as follows and then my code worked.

    pip install asgiref==1.0.0
    
    0 讨论(0)
  • 2021-01-11 13:06

    Just needed to install 'asgi_redis'. I was assuming that it would have gotten installed by default while installing Django-Channels, but it doesn't. 'asgiref' gets installed by default and not 'asgi_redis'. So to solve this issue, one can just run:

    > sudo pip install asgi_redis
    
    0 讨论(0)
  • 2021-01-11 13:12

    I also faced same problem while working with django-channels, by following the documentation examples https://channels.readthedocs.io/en/latest/tutorial/index.html you just need to install channels-redis as

    pip install channels-redis

    to resolve this issue.

    0 讨论(0)
  • 2021-01-11 13:13

    In regard to Utkarsh's reply itt's been renamed to:

    pip install channels_redis
    
    0 讨论(0)
  • 2021-01-11 13:17

    With asgiref-2.3.2 and maybe more, you need to install channel_redis.

    NOT asgi_redis.

    pip install channel_redis
    
    0 讨论(0)
  • 2021-01-11 13:18

    Faced the similar issue. Solved it by installing channels_redis:

    pip install channels_redis
    

    Also using channel redis in setting too:

    CHANNEL_LAYERS = {
        'default': {
            'BACKEND': 'channels_redis.core.RedisChannelLayer',
            'CONFIG': {
                'hosts': [('localhost', 6379)],
            },
        },
        'ROUTING': 'ws.routing.application',
    }
    
    0 讨论(0)
提交回复
热议问题