[Answer]-How to use CSRF token in jinja2?

1👍

I may be wrong but I believe {{ csrf_token }} goes on the inside of your form tag.

<form>{{ csrf_token }}
blah: <input type="text">
<input type="submit">
</form>

0👍

You also need to add django.core.context_processors.csrf to your TEMPLATE_CONTEXT_PROCESSORS setting. Otherwise {{ csrf_token }} won’t have a value.

You’re now probably submitting the form with an empty CSRF token.

Leave a comment