AttributeError: 'NoneType' object has no attribute 'group_add #1805
Unanswered
Dhiraj1424
asked this question in
Help!
Replies: 2 comments
-
In the other issue it was mentioned the problem was in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am getting AttributeError: 'NoneType' object has no attribute 'group_add' error again and again I also tried to use layers but I also got an error.
from channels.generic.websocket import WebsocketConsumer
from asgiref.sync import async_to_sync
import json
class TestConsumer(WebsocketConsumer):
def connect(self):
self.room_name="test_consumer"
self.room_group_name="test_consumer_group"
async_to_sync(self.channel_layer.group_add) (
self.room_name, self.room_group_name
)
self.accept()
self.send(text_data=json.dumps({'status':'you are conn'}))
def recive(self):
pass
def disconnect(self):
pass
asgi.py
from django.urls import path
from home.consumers import*
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
application = get_asgi_application()
WS_PATTERNS=[
path('ws/test/',TestConsumer.as_asgi()),
]
application=ProtocolTypeRouter({
'websocket':URLRouter(WS_PATTERNS)
})
Beta Was this translation helpful? Give feedback.
All reactions