CSRF token missing or incorrect, even after including the token tag

前端 未结 1 717
北恋
北恋 2020-12-12 06:54

I am getting a \'CSRF token missing or incorrect\' error, but I have already added the {% csrf_token%} tag in the web form. Any idea why I still face this error

相关标签:
1条回答
  • 2020-12-12 07:37

    It looks like your problem is enctype="text/plain" in your form. The CSRF protection assumes that the post data is form encoded.

    The simplest fix is to remove that entirely, which is equivalent to:

    enctype="enctype=application/x-www-form-urlencoded"
    

    If you were uploading files in your form you would use:

    enctype="multipart/form-data"
    
    0 讨论(0)
提交回复
热议问题