Different value of csrf token in response header and browser cookies. csrf verification failing in django 1.9

前端 未结 1 1646
情话喂你
情话喂你 2021-01-13 03:46

Most of the SO answers are asking to clear cookies and confirm middleware class. I have already tried that.

Python - 3.4
Django - 1.10
Using

相关标签:
1条回答
  • 2021-01-13 04:41

    The unexpected value for the CSRF token is set when the browser tries to fetch the favicon.

    The URL you have defined for your favicon seems to be invalid, and apparently, non-existing URLs are handled by your default view. This sets a different CSRF cookie, but the page that is displayed in the browser still has the initial CSRF token in the form.

    Request loading the page:

    Request loading the favicon:

    You can fix this particular error by ensuring that the favicon exists.

    Note this this bug will come back whenever any resource you link (e.g. an image) does not exist because your app renders the homepage instead of returning a 404 error.

    0 讨论(0)
提交回复
热议问题