只有首页显示表中的数据。
views.py
def编辑(请求): host_name_id = request.GET.get('host_name') 打印(host_name_id) 人= Person.objects.filter(host_name_id = host_name_id).all() 打印(人)
paginator = Paginator(person, 3)
page = request.GET.get('page')
page1 = paginator.page(1)
print(page1.object_list)
person = paginator.get_page(page)
try:
users = paginator.page(page)
except PageNotAnInteger:
users = paginator.page(1)
except EmptyPage:
users = paginator.page(paginator.num_pages)
return render(request,"testapp/person_form.html",{'person':person, 'users':users})
person_form.html
主机名 接口 描述 服务质量 虚拟局域网 客户状态 接口IP 子网掩码 广域网 局域网池 市 {%for person in person%} {{item.host_name}} {{item.interface}} {{ 商品描述 }} {{item.qos}} {{item.vlan}} {{item.customer_status}} {{item.interface_ip}} {{item.subnet}} {{item.van_network}} {{item.ip_network}} {{item.city}} {%endfor%} {%,如果是users.has_other_pages%} {%如果users.has_previous%}