djangodocs.org

159 sections in Django dev Search all versions →

Security

Reference System check framework

security.W003: You don’t appear to be using Django’s built-in cross-site request forgery protection via the middleware (django.middleware.csrf.CsrfViewMiddleware is not in your MIDDLEWARE). Enabling the middleware is the safest approach to ensure you don’t leave any holes.

C

Index

… csp() (in module django.template.context_processors) - csp_nonce_attr - template tag - csp_override() (in module django.views.decorators.csp) - csp_report_only_override() (in module django.views.decorators.csp) - CSRF_COOKIE_AGE - setting - CSRF_COOKIE_DOMAIN - setting - CSRF_COOKIE_HTTPONLY - setting - CSRF_COOKIE_NAME - setting - CSRF_COOKIE_PATH - setting - …

R

Index

… attribute) - required_db_vendor (Options attribute) - REQUIRED_FIELDS (models.CustomUser attribute) - RequireDebugFalse (class in django.utils.log) - RequireDebugTrue (class in django.utils.log) - requires_csrf_token() (in module django.views.decorators.csrf) - requires_migrations_checks (BaseCommand attribute) - requires_settings (BaseCommand attribute) - requires_system_checks (BaseCommand attribute) - reset_sequences (TransactionTestCase attribute) …

CSRF

Release notes Django 1.11 release notes

Added the CSRF_USE_SESSIONS setting to allow storing the CSRF token in the user’s session rather than in a cookie.

Release notes Django 1.2 release notes

CsrfResponseMiddleware, the middleware that automatically inserted CSRF tokens into POST forms in outgoing pages, has been deprecated in favor of a template tag method (see above), and will be removed completely in Django 1.4.

Release notes Django 4.1 release notes

The new CSRF_COOKIE_MASKED transitional setting allows specifying whether to mask the CSRF cookie. CsrfViewMiddleware no longer masks the CSRF cookie like it does the CSRF token in the DOM.

Miscellaneous

Release notes Django 1.10 release notes

CSRF token values are now required to be strings of 64 alphanumerics; values of 32 alphanumerics, as set by older versions of Django by default, are automatically replaced by strings of 64 characters. Other values are considered invalid.

Decorators

Release notes Django 5.0 release notes

The following decorators now support wrapping asynchronous view functions: cache_control() never_cache() no_append_slash() csrf_exempt() csrf_protect() ensure_csrf_cookie() requires_csrf_token() sensitive_variables() sensitive_post_parameters() gzip_page() condition() conditional_page() etag() last_modified() require_http_methods() require_GET() require_POST() require_safe() vary_on_cookie() vary_on_headers() xframe_options_deny() xframe_options_sameorigin() xframe_options_exempt()

Release notes

This release corrects the following problems: The patch applied for the security issue covered in Django 1.2.2 caused issues with non-ASCII responses using CSRF tokens.

One new feature

Release notes Django 1.1.2 release notes

Django 1.2 (the next major release of Django) will contain a feature that will improve protection against Cross-Site Request Forgery (CSRF) attacks. This feature requires the use of a new csrf_token template tag in all forms that Django renders.

Bugfixes

Release notes Django 1.11.6 release notes

Fixed a regression in Django 1.9 where a custom view error handler such as handler404 that accesses csrf_token could cause CSRF verification failures on other pages (#28488).

Bugfixes

Release notes Django 1.5.2 release notes

The CSRF token now rotates when a user logs in. Some Python 3 compatibility fixes including #20212 and #20025. Fixed some rare cases where get() exceptions recursed infinitely (#20278). makemessages no longer crashes with UnicodeDecodeError (#20354).