为什么Django管理员登录给我403 CSRF错误? [英] Why is Django admin login giving me 403 CSRF error?

查看:539
本文介绍了为什么Django管理员登录给我403 CSRF错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Django 1.2.2,当我尝试登录Django管理员时,我收到以下错误:

I am running Django 1.2.2 and I get the following error when I try to log in to the Django admin:


禁止(403)CSRF验证
失败。请求已中止。

Forbidden (403) CSRF verification failed. Request aborted.

发生故障的原因:

没有CSRF或会话cookie。

No CSRF or session cookie.

**我没有对准系统管理员进行定制,当我检查源代码时,表单中有一个CSRF令牌,我相信是正确的地方

** I have made NO customization to the barebones admin and when I inspect the source there is a CSRF token in the form in what I believe is the correct place.

当我查看正在发送的实际请求时,会发送一个csrf令牌,但Django仍然说CSRF验证失败。

When I look at the actual request that is being sent there is a csrf token being sent but Django still says CSRF verification failed.

任何人都可以指向正确的方向吗?为什么会发生这种情况?

Can anyone point me in the right direction? Why is this happening?

推荐答案

1)你有'django.middleware.csrf.CsrfViewMiddleware' 在您的 settings.MIDDLEWARE_CLASSES

2)你确定你一直一直在1.2.2?昨晚才出来...

2) Are you sure you've always been on 1.2.2? That only came out last night...

这篇关于为什么Django管理员登录给我403 CSRF错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆