Chinaunix首页 | 论坛 | 博客
  • 博客访问: 303595
  • 博文数量: 47
  • 博客积分: 1190
  • 博客等级: 少尉
  • 技术积分: 523
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-14 20:30
文章分类

全部博文(47)

文章存档

2016年(1)

2012年(46)

我的朋友

分类: 系统运维

2012-06-27 11:34:32


Forbidden (403)
CSRF verification failed. Request aborted.
More information is available with DEBUG=True.

Solution:

第一种:在表单里加上{% csrf_token %}就行了。

第二种方法是在Settings里的MIDDLEWARE_CLASSES增加配置:
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.csrf.CsrfResponseMiddleware',


Forbidden (403)

CSRF verification failed. Request aborted.

Help

Reason given for failure:

CSRF token missing or incorrect.

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.

阅读(5145) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~