2
votes

I have usually been using render_to_response for my view functions in django.

However, recently, I have been trying to use more of the render method (https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render) which as I understand here from the docs, automatically includes 'context_instance' if none is provided.

How does this optional context_instance argument work in relation to crsf_token? Do I have to explicitly send in a template variable such as "csrf(request)", using something like

template_vars.update(csrf(request))

I am asking about this because I am getting an inexplicable

"Forbidden (403) CSRF verification failed. Request Aborted". 

Even though I have the csrf middleware enabled in my settings.py and in my template, form, a {% csrf_token %} templatetag call.

1

1 Answers

1
votes

Did you forget to add django.core.context_processors.csrf to TEMPLATE_CONTEXT_PROCESSORS?