作者wahahahaaa (hah)
看板Python
标题[问题] django - csrf验证失败
时间Sat Mar 28 15:23:50 2020
最近参考此篇文章:
https://ithelp.ithome.com.tw/articles/10202804 学django
出现以下错误:
https://imgur.com/071onyE
*Your browser is accepting cookies. -> 已检查 ok
*The view function passes a request to the template's render method.
*In the template, there is a {% csrf_token %} ... 参考文中作者所说 ok
*If you are not using CsrfViewMiddleware... 已检查 ok
*The form has a valid CSRF token. After logging in.... --> 已确认 ok
其中四项检查完毕, 第二项不太理解他的意思 想请教该怎麽确认呢? 谢谢
以下是程式码内容
html:
https://imgur.com/Qib370x
settings.py:
https://imgur.com/CvuTfm2
urls.py:
https://imgur.com/lmxw5Uw
views.py:
https://imgur.com/GZvrYJx
感谢拜托大大指导一下
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.43.21.121 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1585380232.A.7DA.html
1F:→ clang: HTML第8行那个不必要,它需要的token要放在form内,吃的是1 03/28 16:29
2F:→ clang: 4行那个 03/28 16:29
3F:→ clang: 不过我不觉得这是错误的原因 03/28 16:29
好的感谢纠正 恩对还是一样403 forbidden错误
4F:推 trew98741: 把 card移到extend後试试 03/28 20:53
5F:→ trew98741: 摆在你的 block content後一行 03/28 20:54
抱歉 card是指csrf吗? 把它放在block content後一行 一样显示错误ㄋ
※ 编辑: wahahahaaa (114.43.21.121 台湾), 03/28/2020 21:47:33
6F:推 trew98741: 对 csrf. 03/28 22:48
7F:推 yuenu: 那你的base.html是写了什麽... 03/30 00:17
8F:→ wahahahaaa: 在检查了两次重打就好了 可能是档案没储存到@@.. 03/30 15:20