Django - CSRF token missing or incorrect

前端 未结 4 1978
失恋的感觉
失恋的感觉 2021-01-04 02:57

I just updated my django to 1.4. But I am getting the following error when I try to submit my login form:

Forbidden (403) CSRF verification failed.

4条回答
  •  -上瘾入骨i
    2021-01-04 03:51

    The code looks fine, Django 1.3 and 1.4 auth.views.login uses RequestContext correctly. Please check:

    • Firstly clear data of browser and try again
    • What's the value of submitted csrfmiddlewaretoken
    • Do you import correct Django?
    • Just make sure, is there UserWarning in console like?: "A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext."

提交回复
热议问题