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
login.html
next 引數傳入 用隱藏的方式
<input type="hidden" name="next" value=https://www.cnblogs.com/Py-beginner/archive/2020/10/26/"{{ next }}">
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/192019.html
標籤:其他
