Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: type object 'ChatConsumer' has no attribute 'as_asgi()

from django.urls import re_path
from . import consumers
websocket_urlpatterns = [
        re_path(r'ws/chat/(?P<room_name>\w+)/$',consumers.ChatConsumer.as_asgi()),]

getting error of as_asgi()

like image 656
Arpit Avatar asked Oct 28 '25 10:10

Arpit


2 Answers

This is because of the version of 'channels'. check the channels version of your channels. It is working with channels 3.0.1. If you had downgraded your channels-redis, channels also will get downgraded.

like image 128
Danish Avatar answered Oct 30 '25 11:10

Danish


Use channels==3.0.1 & you are good to go.

like image 43
Christopher Nolan Avatar answered Oct 30 '25 12:10

Christopher Nolan