Chatroom example problems. #1987
-
I want to create a chatroom between users using channels in my django project! I wrote all the routing, consumer and other python files using the documentation but I got an error. Please help me to fix this error!here is the error i am getting:TypeError: object ChatRoomConsumer can't be used in 'await' expression WebSocket DISCONNECT /ws/chat/asma/ [127.0.0.1:56540] from django.urls import re_path from . import consumers websocket_urlpatterns = [ |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
this consumers.pyimport json from channels.generic.websocket import AsyncWebsocketConsumer class ChatRoomConsumer(AsyncWebsocketConsumer):
|
Beta Was this translation helpful? Give feedback.
-
WSGI_APPLICATION = "hosptalsam.wsgi.application" ASGI_APPLICATION = "hosptalsam.routing.application" |
Beta Was this translation helpful? Give feedback.
-
this hosptalsam/routing.url (core)from message import routing Initialize Django ASGI application early to ensure the AppRegistryis populated before importing code that may import ORM models.django_asgi_app = get_asgi_application() from channels.routing import ProtocolTypeRouter, URLRouter application = ProtocolTypeRouter({ |
Beta Was this translation helpful? Give feedback.
-
asgiref==3.6.0 |
Beta Was this translation helpful? Give feedback.
-
WebSocket HANDSHAKING /ws/chat/asma/ [127.0.0.1:56540] |
Beta Was this translation helpful? Give feedback.
-
You're missing an
|
Beta Was this translation helpful? Give feedback.
You're missing an
.as_asgi()
: