Skip to content

Commit 80ce9a5

Browse files
committed
allow for spaces in the websocket route
1 parent 9d1b72f commit 80ce9a5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

classroom/consumers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def check_user_classroom(self, user, classroom):
2121
async def connect(self):
2222
classroom_code = self.scope["url_route"]["kwargs"]["classroom_code"]
2323
channel_name = self.scope["url_route"]["kwargs"]["channel_name"]
24-
self.group_name = classroom_code + "." + channel_name
24+
self.group_name = classroom_code + "." + channel_name.replace(' ', '')
2525

2626
try:
2727
self.classroom = await database_sync_to_async(Classroom.objects.get)(code=classroom_code,)
@@ -61,7 +61,7 @@ async def receive(self, text_data):
6161
"type": 'chat_message',
6262
"id": message.id,
6363
"user": message.user.username,
64-
"avatar": '/message.user.profile.profile_picture',
64+
"avatar": 'https://static.vecteezy.com/system/resources/previews/024/983/914/non_2x/simple-user-default-icon-free-png.png',
6565
"text": message.text,
6666
}
6767

classroom/routing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from . import consumers
33

44
websocket_urlpatterns = [
5-
re_path(r'ws/(?P<classroom_code>\w+)/(?P<channel_name>\w+)/$', consumers.ChannelConsumer.as_asgi())
5+
re_path(r'ws/(?P<classroom_code>\w+)/(?P<channel_name>[\w\s]+)/$', consumers.ChannelConsumer.as_asgi())
66
]

0 commit comments

Comments
 (0)