Django HTTP Referrer Policy¶
django-referrer-policy provides a middleware class implementing the Referrer-Policy header for Django-powered sites.
Note: Starting from Django v3.0, Django itself has default support
of Referrer-Policy header in SecurityMiddleware
via setting variable SECURE_REFERRER_POLICY
.
Documentation¶
The full documentation is at https://django-http-referrer-policy.readthedocs.io.
Quickstart¶
Install Django HTTP Referrer Policy:
pip install django-http-referrer-policy
Add Django HTTP Referrer Policy Middleware to your settings:
MIDDLEWARE = [
...
'django_http_referrer_policy.middleware.ReferrerPolicyMiddleware',
...
]
Optional: provide variable REFERRER_POLICY to your settings with valid value if default value 'no-referrer-when-downgrade'
does not suit to you:
REFERRER_POLICY = 'no-referrer'
More details about valid referrer policies: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy#Syntax
Running Tests¶
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox