.. _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 ``