Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there something wrong in the manner which I am trying to pass multiple parameters in django url

def index(request):
    if request.method == 'POST':
        global room_name
        room_name = request.POST['room_name']

        if models.chat.objects.filter(room_name=room_name).exists():
            username = request.POST['user_name']
            return redirect('/'+room_name+'username?='+username)

        else:
            messages.info(request,'Room does not exist')
            return redirect(index)
    else:

        return render(request,'home2.html') 

urlpatterns = [
    path('',views.index),
    path('/<str:room>/<str:username>/',views.join_room)
    
]

I am trying to build a chatbox, and hence if this executes perfectly it should redirect the URL as 12….// where room is the chatroom and username is the username of the person logging in. But the following error comes:

Page not found (404)
Request Method: GET
Request URL:    http://127.0.0.1:8000/Familyusername?=Afif 

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Kindly make sure that the parameter name is consistent everywhere.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading