Reputation: 299
I'll give the step by step info.
Let's say we're in the about page, the URL is example.com/about
.
There's an email a friend button, when clicked, the URL is example.com/emailafriend
.
Then when I clicked the submit button, the referal URL will be submitted is example.com/emailafriend
. Question, how to get the about page URL? BTW, I'm using request.META['HTTP_REFERER']
.
Upvotes: 14
Views: 10375
Reputation: 8914
You could work with the request path attribute and add that to your form's action attribute, like so:
<form method="post" action="/tell-a-friend?return_url={{ request.path }}">
...
</form>
Then, in your tell-a-friend view, HttpResponseRedirect to the return_url
query parameter.
Upvotes: 13
Reputation: 508
Maybe simply pass sample.com/about as GET or POST param? Or even through session.
Upvotes: 0
Reputation: 40193
It looks like maybe you are using APPEND_SLASH which will do a redirect if you don't have a slash. Try changing the button link to sample.com/emailafriend/
, note the ending slash.
Upvotes: 1