I use a decorator:
Def check_login (func) :
"' provide login redirect function '
Def wrapper (self, request, * args, * * kwargs) :
# using login session to judge the client state
If the request. The session. The get (' is_login, False) :
Return func (self, request, * args, * * kwargs)
The else:
# not login
Next=request. Get_full_path (#) of the current access url passed to/login/
Res=redirect ('/login/? Next='+ next)
Return res
Return wrapper
Then in the login view using the next this parameter:
The class LoginView (View) :
Def get (self, request) :
.
Def post (self, reuqest) :
.
# to return to the interface of user click
Next=request. GET. GET (' next ', '/')
# redirect page
Return redirect (next)
Use pycharm also examined the value after each jump, found the next has been get, and then log in the address bar is this:
Then when the debug debugging is like this:
Why can not GET the next parameter in this GET? Really don't know where is wrong, baidu also can not find a similar answer, please everyone a great god answer