… in a view function Security in Django Always sanitize user input Cross site scripting (XSS) protection Cross site request forgery (CSRF) protection SQL injection protection Clickjacking protection SSL/HTTPS Host header validation Referrer policy Cross-origin opener policy Session security User-uploaded content …
4.2
5.0
5.1
5.2
6.0
How-to
How to use Django’s CSRF protection
Certain views can have unusual requirements that mean they don’t fit the normal pattern envisaged here. A number of utilities can be useful in these situations. The scenarios they might be needed in are described in the following section.
dev
How-to
How to use Django’s CSRF protection
Certain views can have unusual requirements that mean they don’t fit the normal pattern envisaged here. A number of utilities can be useful in these situations. The scenarios they might be needed in are described in the following section.
4.2
5.0
5.1
5.2
6.0
Release notes
Django 1.9 release notes
The request header’s name used for CSRF authentication can be customized with CSRF_HEADER_NAME. The CSRF referer header is now validated against the CSRF_COOKIE_DOMAIN setting if set. See How it works for details.
dev
Release notes
Django 2.1 release notes
Added the CSRF_COOKIE_SAMESITE setting to set the SameSite cookie flag on CSRF cookies.
dev
Release notes
Django 3.1 release notes
The CSRF_COOKIE_SAMESITE setting now allows 'None' (string) value to explicitly state that the cookie is sent with all same-site and cross-site requests.
dev
Release notes
Django 4.0 release notes
CSRF protection now consults the Origin header, if present. To facilitate this, some changes to the CSRF_TRUSTED_ORIGINS setting are required.
dev
Release notes
Django 6.2 release notes - UNDER DEVELOPMENT
…
dev
Release notes
Django 1.9 release notes
What’s new in Django 1.9Minor features
The request header’s name used for CSRF authentication can be customized with CSRF_HEADER_NAME. The CSRF referer header is now validated against the CSRF_COOKIE_DOMAIN setting if set. See How it works for details.
4.2
5.0
5.1
5.2
6.0
Release notes
Django 2.1 release notes
What’s new in Django 2.1Minor features
Added the CSRF_COOKIE_SAMESITE setting to set the SameSite cookie flag on CSRF cookies.
4.2
5.0
5.1
5.2
6.0
Release notes
Django 3.1 release notes
What’s new in Django 3.1Minor features
The CSRF_COOKIE_SAMESITE setting now allows 'None' (string) value to explicitly state that the cookie is sent with all same-site and cross-site requests.
4.2
5.0
5.1
5.2
6.0
Release notes
Django 4.0 release notes
What’s new in Django 4.0Minor features
CSRF protection now consults the Origin header, if present. To facilitate this, some changes to the CSRF_TRUSTED_ORIGINS setting are required.
4.2
5.0
5.1
5.2
6.0
Release notes
Django 1.3 release notes
Prior to Django 1.2.5, Django’s CSRF-prevention system exempted AJAX requests from CSRF verification; due to security issues reported to us, however, all requests are now subjected to CSRF verification.
dev
Release notes
Django 1.4 release notes
We’ve made various improvements to our CSRF features, including the ensure_csrf_cookie() decorator, which can help with AJAX-heavy sites; protection for PUT and DELETE requests; and the CSRF_COOKIE_SECURE and CSRF_COOKIE_PATH settings, which can improve the security and usefulness of CSRF protection.
dev
Release notes
Django 1.4 release notes
Previously, Django’s CSRF protection provided protection only against POST requests.
dev
Release notes
Django 1.8.15 release notes
An interaction between Google Analytics and Django’s cookie parsing could allow an attacker to set arbitrary cookies leading to a bypass of CSRF protection.
dev
Release notes
Django 1.9.10 release notes
An interaction between Google Analytics and Django’s cookie parsing could allow an attacker to set arbitrary cookies leading to a bypass of CSRF protection.
dev
Release notes
Django 4.0 release notes
dev
Release notes
Django 1.3 release notes
Backwards-incompatible changes in 1.3
Prior to Django 1.2.5, Django’s CSRF-prevention system exempted AJAX requests from CSRF verification; due to security issues reported to us, however, all requests are now subjected to CSRF verification.
4.2
5.0
5.1
5.2
6.0
Release notes
Django 1.4 release notes
What’s new in Django 1.4
We’ve made various improvements to our CSRF features, including the ensure_csrf_cookie() decorator, which can help with AJAX-heavy sites; protection for PUT and DELETE requests; and the CSRF_COOKIE_SECURE and CSRF_COOKIE_PATH settings, which can improve the security and usefulness of CSRF protection.
4.2
5.0
5.1
5.2
6.0