在使用django 的過程中難免的會使用到format表單進行提交,如果出現“CSRF驗證失敗. 相應中斷”.該如何解決呢?
阿新 • • 發佈:2019-01-24
CSRF驗證失敗. 相應中斷.
1).首先,我們可以先看一下出現問題的所在的原因。
- Your browser is accepting cookies.
- The view function passes a
request
to the template'srender
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 usecsrf_protect
csrf_token
template tag, as well as those that accept the POST data.