你应该使用自动使用的
render快捷功能
return render(request, 'template.html'),RequestContext
- 使用
render
https://docs.djangoproject.com/en/2.2/topics/http/shortcuts/ - 添加CSRF中间件https://docs.djangoproject.com/en/2.2/ref/csrf/
- 使用
{% csrf_token %}模板标签 - 确认你看到正在生成CSRF令牌值,并在表单请求中提交了该值



