Reputation: 31
url = request.META.get('HTTP_REFERER')
return HttpResponseRedirect(url)
This URL is used to redirect to the current page and I want to send a parameter with it. How I can do that?
Upvotes: 3
Views: 322
Reputation: 41
import urllib.parse
params = {"test": 1, "q": "some search string"}
query_string = urllib.parse.urlencode(params)
url = request.META.get('HTTP_REFERER')
if not url:
url = request.META.get('some-other-header')
url += "?" + query_string
Upvotes: 0