标签:tin 方法 视图 submit eth div post 防止 src
def csrf1(request):
return render(request,‘booktest/csrf1.html‘)
def csrf2(request):
uname=request.POST[‘uname‘]
return render(request,‘booktest/csrf2.html‘,{‘uname‘:uname})
url(r‘^csrf1/$‘, views.csrf1),
url(r‘^csrf2/$‘, views.csrf2),
<html>
<head>
<title>Title</title>
</head>
<body>
<form method="post" action="/crsf2/">
<input name="uname"><br>
<input type="submit" value="提交"/>
</form>
</body>
</html>
<html>
<head>
<title>Title</title>
</head>
<body>
{{ uname }}
</body>
</html>
<form>
{% csrf_token %}
...
</form>
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def csrf2(request):
uname=request.POST[‘uname‘]
return render(request,‘booktest/csrf2.html‘,{‘uname‘:uname})
<input type=‘hidden‘ name=‘csrfmiddlewaretoken‘ value=‘nGjAB3Md9ZSb4NmG1sXDolPmh3bR2g59‘ />
标签:tin 方法 视图 submit eth div post 防止 src
原文地址:http://www.cnblogs.com/huwei934/p/6978687.html