【问题标题】:DJango Post csrf_token invalid and /favicon.ico not foundDJango Post csrf_token 无效并且找不到 /favicon.ico
【发布时间】:2022-12-03 17:44:15
【问题描述】:

I got a problem with DJango. Im trying to send data to a SQL Database in DJango. So I need my token, which I get with {{ csrf_token }}. But when I send the data on the HTML Website, it tells me POST 403 Forbidden and the DJango Terminal says NotFound: /favicon.ico, as well as Forbidden (CSRF token from POST has incorrect length.): /ausgeben/

Does anyone have a solution for this. Down below is the code I`m using for the token request.

Thanks!

    let formData = new FormData();
    formData.append(\"name\", name);
    formData.append(\"gewinde\", gewinde);
    formData.append(\"laenge\", laenge);
    formData.append(\"durchmesser\", durchmesser);
    //formData.append(\"containerNR\", containerNR);
    formData.append(\'csrfmiddlewaretoken\', token);

    fetch(\'/ausgeben/\',{
        method: \'POST\',
        body: formData
    });
  • Please provide enough code so others can better understand or reproduce the problem.

标签: javascript django csrf-token


【解决方案1】:
【解决方案2】:
猜你喜欢
  • 2017-03-29
  • 1970-01-01
  • 1970-01-01
  • 2015-07-25
  • 2017-02-08
  • 1970-01-01
  • 1970-01-01
  • 2015-04-25
  • 1970-01-01
相关资源
最近更新 更多