I'll give the step by step info.
Let's say we're in the about page, the url is sample.com/about.
There's an email a friend button, when clicked, the url is sample.com/emailafriend.
Then when i clicked the submit button, the referal url will be submitted is sample.com/emailafriend. Question, how to get the about page url? BTW, i'm using request.META['HTTP_REFERER']
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With