Django - {% csrf_token %} was used in a template, but the context did not provide the value
Your index.html
is rendered without RequestContext
. Try this:
def index(request):
return render_to_response('index.html', context_instance=RequestContext(request))
I also recomend you to use more convenient shortcut render
:
from django.shortcuts import render
def index(request):
return render('index.html')
From docs:
render() is the same as a call to render_to_response() with a context_instance argument that forces the use of a RequestContext.
EDIT:
Thanks @nerdwaller for mentioning, newer versions now needs:
render(request, 'index.html', {params});