I\'m doing wiki in django tutorial and in tutorial earlier version of django is used where csrf token is not compulsory. I\'ve added {% csrf_token %} to the form, however I\'m n
You haven't quite understood step 3 here: you need to use RequestContext to ensure that the context processor is run.
return render_to_response("edit.html", {"page_name" : page_name,
"content" : content},
context_instance=RequestContext(request))
With that, you don't need the c.update(csrf(request))
bit.
You don't need to do anything more.
Just place {% csrf_token %}
into your form and send it via POST.
All other stuff will be done inside django.middleware.csrf.CsrfViewMiddleware
.
You should enable it in your settings.py
(if you haven't done this):
MIDDLEWARE_CLASSES += (`django.middleware.csrf.CsrfViewMiddleware`,)
TEMPLATE_CONTEXT_PROCESSORS += (`django.core.context_processors.csrf`,)
Last line is not required if you use RequestContext
(not a simple Context
) in your templates (Note: render_to_response()
uses Context
when direct_to_template()
uses RequestContext
)