djangodocs.org

309 sections across all versions Narrow to Django 6.0 (current) →

… 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

Edge cases

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

Edge cases

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

CSRF

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

CSRF

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

CSRF

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

CSRF

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

CSRF

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

CSRF

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

CSRF improvements

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

CSRF improvements

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