---
title: '{% csrf_token %}'
description: protects against cross site request forgery.
date: '2026-08-02'
categories:
  - Template Tag
  - Utility
canonical: https://coolify.djangotemplatetagsandfilters.com/tags/csrf_token/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#csrf-token
---

# {% csrf_token %}

protects against cross site request forgery.

## Documentation

The `{% csrf_token %}` tag must be included in all Django forms.

This will generate a hidden `input` in the form like this:

```django
<input type="hidden" name="csrfmiddlewaretoken" value="ogCnWDqYM5XnnkQWaVz49uLeEj5qYYh3RGTnMEAKy3zYsiWZx4PNoCm2ata02pjR">
```

This value will be checked using Django’s built-in middleware to protect against [cross site request forgery](https://docs.djangoproject.com/en/6.0/ref/csrf/).

## Commentary

Use it.
