views.py:
def index(request):
return render_to_response(\'index.html\', {})
def photos(request, artist):
if not artist:
r
Supposing you are using a fairly recent version of Django (1.3/1.4/dev) you should follow these steps :
settings.py
, Add the middleware django.middleware.csrf.CsrfViewMiddleware
to the
MIDDLEWARE_CLASSES
list.{% crsf_token %}
in the form.django.core.context_processors.csrf
context processor is used either by :
RequestContext
from django.template
from django.core.context_processors
from django.template import RequestContext
from django.shortcuts import render_to_response
def my_view(request):
return render_to_response('my_template.html', {}, context_instance=RequestContext(request))
or
from django.core.context_processors import csrf
from django.shortcuts import render_to_response
def my_view(request):
c = {csrf(request)}
return render_to_response('my_template.html', c)
(exhaustive post for posterity and future viewers)