Reputation: 6555
{% csrf_token %}
outputs a with a form field but, what if I just want the value i..e {{ csrf_token.value }}
is this possible? If so how? I have searched online but cannot find any information on how to achieve this.
Upvotes: 7
Views: 1264
Reputation: 6701
The csrf_token
value is added to the context by django.core.context_processors.csrf
, you can use it directly in the template code:
{{ csrf_token }}
This is the value used by the {% csrf_token %}
template tag when rendering the form field.
Upvotes: 11