美文网首页
Django 提交表单遇到403:CSRF verificati

Django 提交表单遇到403:CSRF verificati

作者: LeoDavid | 来源:发表于2018-02-06 20:22 被阅读44次
UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.  This is usually caused by not using RequestContext.
  "A {% csrf_token %} was used in a template, but the context "
  • 根据提示,权限验证没有成功,需要3个地方需要注意
<form method="post" enctype="multipart/form-data">   {% csrf_token %}  
return render_to_response('user/login.html', kwargs,
        RequestContext(request))
 'django.middleware.csrf.CsrfViewMiddleware',

但是我已经设置了这三个地方,还是不停的403,根本没办法。最后更换了views.py里面的方法!成功了

return render(request,'user/login.html',kwargs)
# return render_to_response('user/login.html', kwargs, RequestContext(request))

相关文章

网友评论

      本文标题:Django 提交表单遇到403:CSRF verificati

      本文链接:https://www.haomeiwen.com/subject/qmknzxtx.html