Django web : CSRF verification failed. Request aborted.
来源:互联网 发布:安卓4.4 联系人数据库 编辑:程序博客网 时间:2024/05/16 14:21
Reason given for failure: CSRF cookie not set. In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django's CSRF mechanism has not been used correctly. For POST forms, you need to ensure: * The view function uses RequestContext for the template, instead of Context. * In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL. * If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.You're seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.You can customize this page using the CSRF_FAILURE_VIEW setting.
解决方案:
1、解决方法错误提示里已经给出了。在表单里加上{% csrf_token %}就行了。
2、加上标红的语句 return render_to_response('polls/detail.html',{'poll':p},context_instance=RequestContext(request))
3、views里面加上这个import from django.template import RequestContext
- Django web : CSRF verification failed. Request aborted.
- 【Django】CSRF verification failed. Request aborted.
- Django: CSRF verification failed. Request aborted.
- Django POST CSRF verification failed. Request aborted
- CSRF verification failed. Request aborted
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted.
- CSRF verification failed. Request aborted
- Django CSRF verification failed. Request aborted.的解决办法
- 解决Django CSRF verification failed. Request aborted.的问题
- Django Forbidden (403) CSRF verification failed. Request aborted.
- 关于HTTP协议中的KeepAlive属性
- PHP工厂模式的好处
- 一种比“ini配置文件”和“注册表”更好用的保存“初始化信息”的方法—CArchive类
- PHP高级对象构建 工厂模式的使用
- 正则表达式中/i,/g,/ig,/gi,/m的区别和含义
- Django web : CSRF verification failed. Request aborted.
- Linux下抓包工具tcpdump应用详解
- JS 中的 style.width
- 有趣的测试
- 我的Jquery学习笔记(一)
- ECMBoss企业内容解决方案项目系列之(二)人力资源整合组建项目精英开发团队
- 绘制2D游戏场景
- 为什么jdk中把String类设计成final?
- Linux系统管理员成长经验:十一大工作心得