I added the hidden input "next" in my login.html and it works.

<input type="hidden" name="next" value="{% if next %}{{ next }}{%else
%}/{% endif %}">

Problem now is, I need to go back to the original page.   The steps as
follows:

1) user at original page
2) if user not logged in, then user logs in (@login_required
decorator).
3) sent to a html view with form submission (http://127.0.0.1:8000/
post/create/)
4) now, user should be sent back to original page (send to step 1)

Step 1-3 working fine, but can't send the user back, as in step 4.

In the view I have:

            referrer = request.META.get('HTTP_REFERER', '/')
            return HttpResponseRedirect(referrer)

referrer seems to always equal to = http://127.0.0.1:8000/post/create/,
since I display the empty form first and in the post submission I call
the above code.

Is there a way to have "previous" generated by decorator
@login_required, so as to get something like this, ?next=/post/create/?
previous=/somepage/.

Then I can pass "previous" as hidden input between html and the view:
<input type="hidden" name="previous" value="{% if previous %}
{{ previous }}{%else %}/{% endif %}">

and in the view:

            referrer = request.META.get('previous', '/')
            return HttpResponseRedirect(referrer)




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to