标签:obj 基础 相关 turn oct object render 异常 val
from django.core.paginator import Paginator
def pagTest(request, pIndex):
list1 = AreaInfo.objects.filter(aParent__isnull=True)
p = Paginator(list1, 10)
if pIndex == ‘‘:
pIndex = ‘1‘
pIndex = int(pIndex)
list2 = p.page(pIndex)
plist = p.page_range
return render(request, ‘booktest/pagTest.html‘, {‘list‘: list2, ‘plist‘: plist, ‘pIndex‘: pIndex})
url(r‘^pag(?P<pIndex>[0-9]*)/$‘, views.pagTest, name=‘pagTest‘),
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<ul>
{%for area in list%}
<li>{{area.id}}--{{area.atitle}}</li>
{%endfor%}
</ul>
{%for pindex in plist%}
{%if pIndex == pindex%}
{{pindex}}
{%else%}
<a href="/pag{{pindex}}/">{{pindex}}</a>
{%endif%}
{%endfor%}
</body>
</html>
标签:obj 基础 相关 turn oct object render 异常 val
原文地址:http://www.cnblogs.com/huwei934/p/6978727.html