Django 对于CSRF verification failed.错误的解决方法
2013-04-24 14:03
316 查看
当使用表单提交的时候,产生错误,错误信息如下:
CSRF verification failed. Request aborted.
测试可行的解决方法(django文档—CSRF):
1.在模板的form中加入{% csrf_token %}
In any template that uses a POST form, use the csrf_token tag
inside the <form> element if the form is for an internal URL, e.g.:
This should not be done for POST forms that target external URLs, since that would cause the CSRF token to be leaked, leading to a vulnerability.
2.修改views.py,注意红色标记处
Forbidden (403)
CSRF verification failed. Request aborted.测试可行的解决方法(django文档—CSRF):
1.在模板的form中加入{% csrf_token %}
In any template that uses a POST form, use the csrf_token tag
inside the <form> element if the form is for an internal URL, e.g.:
<form action="." method="post">{% csrf_token %}
This should not be done for POST forms that target external URLs, since that would cause the CSRF token to be leaked, leading to a vulnerability.
2.修改views.py,注意红色标记处
from django.shortcuts import render_to_response from django.template import RequestContext def sysconfig(request): return render_to_response('SysConfig.html',locals(),RequestContext(request))
相关文章推荐
- Django POST请求 错误 forbidden(403) CSRF verification failed. Request aborted 解决方法
- 解决Django 提交表单时403错误:CSRF verification failed. Request
- Django POST常见的错误:CSRF verification failed. Request aborted.
- django种表单post出现CSRF verification failed( CSRF验证失败 ) 的两种解决方式
- 解决Django CSRF verification failed. Request aborted.的问题
- Django提交POST表单“CSRF verification failed. Request aborted”问题的解决
- [python]CSRF verification failed. Request aborted.的解决方法
- Django CSRF verification failed. Request aborted.的解决办法
- 解决Django 提交表单时403错误:CSRF verification failed. Request aborted .
- [Django与表单]表单 CSRF verification failed 报错的解决
- Django:Forbidden (403) CSRF verification failed. Request aborted. 解决之道
- 解决django开发中CSRF verification failed. Request aborted.的问题
- Django POST常见的错误:CSRF verification failed. Request aborted.
- 解决Django 提交表单时403错误:CSRF verification failed. Request aborted .
- [Django1.4]使用post表单:CSRF verification failed. Request aborted.错误
- django中post提交表单时错误:CSRF verification failed. Request aborted
- 对于重装系统后,迅雷弹出“init task manager failed”错误解决方法
- php提示Failed to write session data错误的解决方法
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
- android 中向手机端安装apk 的时候报出 INSTALL_FAILED_INSUFFICIENT_STORAGE 错误的解决方法