diff --git a/docs/howto/csrf.txt b/docs/howto/csrf.txt new file mode 100644 index 0000000000..eb39c94717 --- /dev/null +++ b/docs/howto/csrf.txt @@ -0,0 +1,309 @@ +.. _using-csrf: + +=================================== +How to use Django's CSRF protection +=================================== + +To take advantage of CSRF protection in your views, follow these steps: + +#. The CSRF middleware is activated by default in the :setting:`MIDDLEWARE` + setting. If you override that setting, remember that + ``'django.middleware.csrf.CsrfViewMiddleware'`` should come before any view + middleware that assume that CSRF attacks have been dealt with. + + If you disabled it, which is not recommended, you can use + :func:`~django.views.decorators.csrf.csrf_protect` on particular views + you want to protect (see below). + +#. In any template that uses a POST form, use the :ttag:`csrf_token` tag inside + the ``