Home > Back-end >  Is there something wrong in the manner which I am trying to pass multiple parameters in django url
Is there something wrong in the manner which I am trying to pass multiple parameters in django url

Time:04-11

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 

CodePudding user response:

Kindly make sure that the parameter name is consistent everywhere.

  • Related