标签:query method htm 开发 request django pwd type post
def postTest1(request):
return render(request,‘booktest/postTest1.html‘)
url(r‘^postTest1$‘,views.postTest1)
<html>
<head>
<title>Title</title>
</head>
<body>
<form method="post" action="/postTest2/">
姓名:<input type="text" name="uname"/><br>
密码:<input type="password" name="upwd"/><br>
性别:<input type="radio" name="ugender" value="1"/>男
<input type="radio" name="ugender" value="0"/>女<br>
爱好:<input type="checkbox" name="uhobby" value="胸口碎大石"/>胸口碎大石
<input type="checkbox" name="uhobby" value="跳楼"/>跳楼
<input type="checkbox" name="uhobby" value="喝酒"/>喝酒
<input type="checkbox" name="uhobby" value="爬山"/>爬山<br>
<input type="submit" value="提交"/>
</form>
</body>
</html>
def postTest2(request):
uname=request.POST[‘uname‘]
upwd=request.POST[‘upwd‘]
ugender=request.POST[‘ugender‘]
uhobby=request.POST.getlist(‘uhobby‘)
context={‘uname‘:uname,‘upwd‘:upwd,‘ugender‘:ugender,‘uhobby‘:uhobby}
return render(request,‘booktest/postTest2.html‘,context)
url(r‘^postTest2$‘,views.postTest2)
<html>
<head>
<title>Title</title>
</head>
<body>
{{ uname }}<br>
{{ upwd }}<br>
{{ ugender }}<br>
{{ uhobby }}
</body>
</html>
标签:query method htm 开发 request django pwd type post
原文地址:http://www.cnblogs.com/huwei934/p/6978637.html