标签:请求 django 属性 连接 开发人员 return head inner div
def getTest1(request):
return render(request,‘booktest/getTest1.html‘)
def getTest2(request):
return render(request,‘booktest/getTest2.html‘)
def getTest3(request):
return render(request,‘booktest/getTest3.html‘)
url(r‘^getTest1/$‘, views.getTest1),
url(r‘^getTest2/$‘, views.getTest2),
url(r‘^getTest3/$‘, views.getTest3),
<html>
<head>
<title>Title</title>
</head>
<body>
链接1:一个键传递一个值
<a href="/getTest2/?a=1&b=2">gettest2</a><br>
链接2:一个键传递多个值
<a href="/getTest3/?a=1&a=2&b=3">gettest3</a>
</body>
</html>
def getTest2(request):
a=request.GET[‘a‘]
b=request.GET[‘b‘]
context={‘a‘:a,‘b‘:b}
return render(request,‘booktest/getTest2.html‘,context)
<html>
<head>
<title>Title</title>
</head>
<body>
a:{{ a }}<br>
b:{{ b }}
</body>
</html>
def getTest3(request):
a=request.GET.getlist(‘a‘)
b=request.GET[‘b‘]
context={‘a‘:a,‘b‘:b}
return render(request,‘booktest/getTest3.html‘,context)
<html>
<head>
<title>Title</title>
</head>
<body>
a:{% for item in a %}
{{ item }}
{% endfor %}
<br>
b:{{ b }}
</body>
</html>
标签:请求 django 属性 连接 开发人员 return head inner div
原文地址:http://www.cnblogs.com/huwei934/p/6978632.html