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 "
- 根据提示,权限验证没有成功,需要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))