python3 之 天天生鲜 项目 next参数
next参数作用
- 在没有登陆时,如果访问了用户地址页面,装饰器
@login_required会限制页面访问 - 在限制页面访问时,该操作被引导到用户登陆界面
- next参数用于标记,从哪儿来,回哪儿去。从用户地址页来就回到用户地址页去
在没有登陆时,如果访问了只有登录才能访问的页面 例如:用户中心、用户地址等

在没有登陆时,访问了用户地址 跳转过来的next参数通过get的方法获取 在传参到form表单 通过POST方式获取到
class LoginView(View):
def get(self,request):
next = request.GET.get("next")
return render(request,"login.html",{"next":next})
def post(self,request):
next = request.POST.get("next")
if next:
return redirect(next)
response = redirect("/goods/index")
return response

![python3 之 天天生鲜 项目 next参数[Python常见问题]](https://www.zixueka.com/wp-content/uploads/2023/10/1696831307-1b203741c180636.jpg)
