I am having problems redirecting to the same page on which the user was turned on after logging in, no matter how hard I try and read all the questions here. I think the time has come when I showed people my code, so if you can point out the error (s). Thanks.
My login url (in the template base.html): This is present on every page. Changes for logging out after a user logs in. I read that I need to pass a parameter, like "next", like this:
<a href="/login/?next={{request.path}}">Login</a>
but
* {{request.path}} always empty. *
logon type:
def mylogin(request): """login view""" try: redirect_to = request.GET.get('next', '/') except ValueError: redirect_to = "/" errors = '' t = loader.get_template('login.html')
Login form for login.html template
<form method="post" action="?next={{ redirect_to }}" > <p><label for="username">Username</p> <p></label><input type="text" name="username" value="" id="username" /></p> <p><label for="password">Password</label></p> <p><input type="password" name="password" value="" id="password" /></p> <p><input type="submit" value="Login"></p> </form>
user201788
source share