仅在django分页中工作的第一页第二页onwords数据未显示

时间:2019-06-21 08:21:47

标签: django-pagination

只有首页显示表中的数据。

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%}                           
  • «
  •                         {%else%}                         «                         {% 万一 %}                         {代表i在users.paginator.page_range%中的百分比}                           {如果users.number == i%,则为%}                             {{i}}(当前)                                                       {%else%}                           
  • {{i}}
  •                         {% 万一 %}                       {%endfor%}                       {%如果users.has_next%}                         
  • »
  •                           {%else%}                           »                           {% 万一 %}                                              {% 万一 %}                                  

    0 个答案:

    没有答案