CSRF verification failed. Request aborted.

在django中,提交表单到内部url必须在form中添加{%csrf-token%}字段。但是加了该字段程序却仍有可能出错(CSRF verification failed. Request aborted.)。原因在于表单处理方法中不能使用render_to_response,而只能使用render。若要使用render_to_response则须在其参数中加上context_instance=RequestContext(request)。

posted @ 2015-07-06 17:34  他们的热闹  阅读(84)  评论(0编辑  收藏  举报