Add the "next" variable as part of the form in a hidden field
<form....>
<input type="hidden" name="next" value="{{ next }}" />
... other fields...
</form>
and then you can get it in the view that handles the login
Also, you seem to have a form object, why don't you use "form.as_p" or
something like that to render the form?
On Fri, Jan 9, 2015 at 2:02 AM, Robin Lery <[email protected]> wrote:
> Suppose this is the url after
> `@login_required(login_url='/accounts/required_login/')`:
>
> http://ngoksy.com/accounts/login_required/?next=/article/
>
> view for the login_require:
>
>
> * def required_login(request): return render(request,
> 'required_login.html')*
>
> I tried adding 'next', like it [here][1]:
>
>
>
> * def required_login(request): c = {'next' :
> request.GET.get('next', '/')} return render(request,
> 'login_required.html', c)*
>
> But it didn't help.
>
> I have different template for login and another template for anonymous
> user which is redirected by `@login_required`.
>
> required_login.html:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> * <h2>Login required! You must login to view the content.</h2> {%
> if form.error %} <p class="error">Sorry, invalid
> username/password!</p> {% endif %} <form
> action="/accounts/auth/" method="post"> {%csrf_token%}
> <label for="username">Username:</label> <input type="text"
> name="username" id="username" value=""> <label
> for="password">Password:</label> <input type="password"
> name="password" id="password" value=""> <input type="submit"
> value="LOGIN"> </form>*
>
> I want to pass the `next` variable after successful login of
> `login_required()`, and land into Articles page after that. How do I do
> that? Please help me understand. Your help will be greatly appreciated.
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B4-nGqds1Ex9Rrw9temyN2D7utJ0FkF7b_sTcOyO7strxt2nw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGqds1Ex9Rrw9temyN2D7utJ0FkF7b_sTcOyO7strxt2nw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CALn3ei2Ut_6mQRO-3et0riOfYfpEoQErCpT%3DE5yrEuoZOFSJ%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.