需求
我需要接受来自ajax传递给我的参数name的值
window.location.href="http://localhost:8000/succ/?name="+name;
解决方案如下
其他地方的路由以及路径啥的都不需要改动,只需要在views.py里面增加以下的代码就可以了
def success(request):
result=""
for k, v in request.GET.items():
result=v
print("result:",result)
return render(request,'success.html',{'username':result})