[Django]-How to set HTTP_REFERER header in a Django view?

3👍

request.META is a dictionary, so you simply do:

self.request.META['HTTP_REFERER'] = '/example/uri/here/'

I’m not sure why you would want to do this. Note that the original header will contain the domain.

1👍

In your view’s response, you can set or modify HTTP header fields:

response = HttpResponse()
response['REFERER'] = '/example/uri/here/'
return response

Leave a comment