CSRF verification failed. Request aborted

后端 未结 10 1966
执笔经年
执笔经年 2020-12-01 13:04

I try to build a very simple website where one can add data into sqlite3 database. I have a POST form with two text input.

index.html:

{% if top_list         


        
10条回答
  •  余生分开走
    2020-12-01 13:18

    If you put {%csrf_token%} and still you have the same issue, please try to change your angular version. This worked for me. Initially I faced this issue while using angular 1.4.x version. After I degraded it into angular 1.2.8, my problem was fixed. Don't forget to add angular-cookies.js and put this on your js file.
    If you using post request.

    app.run(function($http, $cookies) {
        console.log($cookies.csrftoken);
        $http.defaults.headers.post['X-CSRFToken'] = $cookies.csrftoken;
    });
    

提交回复
热议问题