标签:return 数据分页 列表 参数 parent ali The rev doctype
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>
标签:return 数据分页 列表 参数 parent ali The rev doctype
原文地址:https://www.cnblogs.com/alexzhang92/p/9529733.html