1、不推荐禁用掉django中的CSRF。

2、我们可以再html页面的form表单中添加csrf_token,带着表单的请求一起发送到服务器去验证。

<form  enctype="multipart/form-data" method="post" action="{% url 'new_article' %}">
{% csrf_token %}
  .....
</form>
 

3、在后端一定要使用render()的方法返回数据。

return render(request, 'article_new.html', {'article_list': article_list})

相关文章:

  • 2021-12-20
  • 2022-12-23
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2021-06-16
  • 2022-01-07
猜你喜欢
  • 2021-12-16
  • 2021-12-20
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案