To extract the csrf token itself, you need to resort to using some of the internal components of Django. First, include this line at the top of your view.
from django.middleware.csrf import get_token
Now, passing the parameters to your template, do something like
def my_view(request):
return render_to_response("index.html", {"csrf_token": get_token(request)})
In the template, just specify the token with {{ csrf_token }}.
source
share