简体   繁体   English

Django Admin CSRF Coo​​kie问题

[英]Django Admin CSRF Cookie issue

我有一个带有django管理面板的网站,它工作正常,但是我看到刷新管理面板中的表单时,csrf cookie无法重新生成,它显示相同的内容。

Note that the CSRF token is not regenerated on page load. 请注意,CSRF令牌不会在页面加载时重新生成。 It is normal to see the same token used repeatedly. 看到相同的令牌反复使用是正常的。

In Django, the CSRF token is set to a random value for each session - it is also known as "session independent nonce". 在Django中,每个会话的CSRF令牌均设置为随机值-也称为“会话无关的随机数”。 Other sites will not be able to access the CSRF token value in the cookie. 其他站点将无法访问cookie中的CSRF令牌值。 If you create a new session, a new CSRF token will be used. 如果创建新会话,将使用新的CSRF令牌。

When you submit a form, Django will check that the CSRF token submitted in the form data matches the one in the cookie. 提交表单时,Django将检查表单数据中提交的CSRF令牌是否与Cookie中的令牌匹配。

See https://docs.djangoproject.com/es/1.9/ref/csrf/#how-it-works for more information. 有关更多信息,请参见https://docs.djangoproject.com/es/1.9/ref/csrf/#how-it-works

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM