Django Channels

34 views
Skip to first unread message

Vaibhav Kumar Chaudhary

unread,
Jan 27, 2019, 1:06:49 PM1/27/19
to Django users
I am trying to create a chat app with Django Channels and facing a bit problem here.
when I type chat room's name is the form it redirects with to that link but my urls .py can not match that url and can not connect me to my views 

here is urls.py 
from django.urls import path
from django.conf.urls import url
from . import views
urlpatterns=[
   path('chat',views.index,name='index'),
   path('chat/<str:room_name>',views.room,name='room'),
   
]


for example, if I enter lobby it should redirect me to /chat/lobby/

this is my javascript code to redirecting
document.querySelector('#room-name-submit').onclick = function(e) {
           var roomName = document.querySelector('#room-name-input').value;
           window.location.pathname = '/chat/' + roomName + '/';
       };

Please help me where I am wrong

mahesh boini

unread,
Jan 28, 2019, 7:20:10 AM1/28/19
to django...@googlegroups.com
path('chat/<str:room_name>/',views.room,name='room')  replace this and try i just added "/"

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/16083864-abac-47ae-b0ec-601d1912220b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages