[問題] django - csrf驗證失敗

看板Python作者 (hah)時間5年前 (2020/03/28 15:23), 5年前編輯推噓3(305)
留言8則, 4人參與, 5年前最新討論串1/1
最近參考此篇文章: 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

03/28 16:29, 5年前 , 1F
HTML第8行那個不必要,它需要的token要放在form內,吃的是1
03/28 16:29, 1F

03/28 16:29, 5年前 , 2F
4行那個
03/28 16:29, 2F

03/28 16:29, 5年前 , 3F
不過我不覺得這是錯誤的原因
03/28 16:29, 3F
好的感謝糾正 恩對還是一樣403 forbidden錯誤

03/28 20:53, 5年前 , 4F
把 card移到extend後試試
03/28 20:53, 4F

03/28 20:54, 5年前 , 5F
擺在你的 block content後一行
03/28 20:54, 5F
抱歉 card是指csrf嗎? 把它放在block content後一行 一樣顯示錯誤ㄋ ※ 編輯: wahahahaaa (114.43.21.121 臺灣), 03/28/2020 21:47:33

03/28 22:48, 5年前 , 6F
對 csrf.
03/28 22:48, 6F

03/30 00:17, 5年前 , 7F
那你的base.html是寫了什麼...
03/30 00:17, 7F

03/30 15:20, 5年前 , 8F
在檢查了兩次重打就好了 可能是檔案沒儲存到@@..
03/30 15:20, 8F
文章代碼(AID): #1UVlk8VQ (Python)
文章代碼(AID): #1UVlk8VQ (Python)