我尝试在 django 中传递多个参数的方式有问题 url
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)
]
我正在尝试构建一个聊天框,因此如果它执行得很好,它应该将 URL 重定向为 12....// 其中 room 是聊天室,username 是登录者的用户名in. 但是出现如下错误:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/Familyusername?=Afif
请确保参数名称各处一致。
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)
]
我正在尝试构建一个聊天框,因此如果它执行得很好,它应该将 URL 重定向为 12....// 其中 room 是聊天室,username 是登录者的用户名in. 但是出现如下错误:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/Familyusername?=Afif
请确保参数名称各处一致。