django csrf 求助
昨天 刚用IIS部署了一个django应用 ;昨天部署完后 有正常访问的;
今天再去访问的时候 , 却提示 crsf 中断;
Help
Reason given for failure:
CSRF token from POST 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:
Your browser is accepting cookies.
The view function passes a request to the template’s render method.
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.
The form has a valid CSRF token. After logging in in another browser tab or hitting the back button after a login, you may need to reload the page with the form, because the token is rotated after a login.
检查了settings确实是启用了 全局 crsf; 也检查了模板,form表单下也确实 添加了 {% csrf_token %}
主要是 昨天还能好好 正确 访问,今天却整这么一出。。
在线求教 , 高手指引指引 看提示,似乎是cookie没有正确更新?没获取到? 具体不太清楚。。
另外,可以了解它提到的 csrf_protest 或csrf_exempt, 装饰一下那个视图,试试看。还有看看你的表单提交后是否正确重定向了。
好奇你为什么用IIS? 通常不是用apache(httpd)、Nginx等,或其他Lixus系的服务器吗? Windows的IIS,反正我是没用过的。。
页:
[1]