作者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://www.ptt.cc/bbs/Python/M.1585380232.A.7DA.html
→ clang: HTML第8行那個不必要,它需要的token要放在form內,吃的是1 03/28 16:29
→ clang: 4行那個 03/28 16:29
→ clang: 不過我不覺得這是錯誤的原因 03/28 16:29
好的感謝糾正 恩對還是一樣403 forbidden錯誤
推 trew98741: 把 card移到extend後試試 03/28 20:53
→ trew98741: 擺在你的 block content後一行 03/28 20:54
抱歉 card是指csrf嗎? 把它放在block content後一行 一樣顯示錯誤ㄋ
※ 編輯: wahahahaaa (114.43.21.121 臺灣), 03/28/2020 21:47:33
推 trew98741: 對 csrf. 03/28 22:48
推 yuenu: 那你的base.html是寫了什麼... 03/30 00:17
→ wahahahaaa: 在檢查了兩次重打就好了 可能是檔案沒儲存到@@.. 03/30 15:20