django, CSRF token missing or incorrect

1518 ワード

CSRF token missing or incorrect

--

 

1   templete  ,     POST form      {% csrf_token %} tag.   :

 

<form>

    {% csrf_token %}

</form>

 

2   view  ,    django.template.RequestContext     Context.

 

render_to_response,      Context.      RequestContext.

 

   class:

 

from django.template import RequestContext

 

  render_to_response       :

 

def your_view(request):

    ...

    return render_to_response('template.html',

          your_data,

          context_instance=RequestContext(request)

    )