CSRF verification failed. Request aborted.
默认会出现该状况,解决办法:
1. 使用requestcontext
from django.template import RequestContext
…
…
return render_to_response('my_template.html',
my_data_dictionary,
context_instance=RequestContext(request))
2.在表单中添加tag
<form action="/contact/" method="post">{% csrf_token %}
3.setting.py中MIDDLEWARE_CLASSES加入'django.middleware.csrf.CsrfViewMiddleware'
注:浏览器需要接受cookies,第三步如果不执行,则需要在post表单对应视图头部加入@csrf_protect
或者直接注释掉settings.py的MIDDLEWARE_CLASSES中的'django.middleware.csrf.CsrfViewMiddleware',