As I am following the Django channels tutorial (here is the link:
https://channels.readthedocs.io/en/latest/tutorial/part_2.html
), I won't post any code except the specific problem I am having.
In my code for the chat/routing.py, I have:
from django.urls import re_path
from . import consumers
websocket_urlpatterns = [
re_path(r'ws/chat/(?P<room_name>\w+)/$', consumers.ChatConsumer.as_asgi()),
]
which seems to be identical to that which is given in the tutorial. Trying both single and double quotes, I get the error:
SyntaxWarning: invalid escape sequence '\w'
r"ws/chat/(?P<room_name>\w+)/$", consumers.ChatConsumer.as_asgi()
Everything I can find says one is supposed to pre-pend the r to make the expression a regular expression, but clearly I have done so to no effect. What am I doing wrong? Have I missed something? I have copied the line from the tutorial and compared it to mine and it is identical. Thanks in advance.
\wto\d(or something else) and see if the warning still says\w.\\w+, so change tore_path(r"ws/chat/(?P<room_name>\\w+)/$", consumers.ChatConsumer.as_asgi())\\wwould have two actual backslashes, which would not be correct in this context.