Django 提交表单遇到403:CSRF verificati

2018-02-06  本文已影响44人  LeoDavid
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 "
<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))
上一篇 下一篇

猜你喜欢

热点阅读