django viewList 中实现分页功能
来源:互联网 发布:矩阵防御 编辑:程序博客网 时间:2024/05/16 12:57
views.py:
from django.shortcuts import renderfrom django.views.generic import ListViewfrom .models import AttendanceList# Create your views here.class AttendanceListIndex(ListView): context_object_name = 'attendanceListlist' template_name = 'attendance/Node/index.html' paginate_by = 1 #每页显示的条目数 model =AttendanceList
工程url.py:
from django.conf.urls import url,includefrom django.contrib import adminurlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^attendance/', include('attendance.urls')),]
app 中url.py :
from django.conf.urls import urlfrom django.views.generic import TemplateViewfrom views import AttendanceListIndexurlpatterns = [ url(r'^index/$', TemplateView.as_view(template_name="attendance/index.html")), url(r'^Node/index.html/$',AttendanceListIndex.as_view(),name='showattendance')]
attendance/Node/index.html:
{% if is_paginated %} <div class="pagination"> <span class="page-links"> {% if page_obj.has_previous %} <a href="/attendance/Node/index.html/?page={{ page_obj.previous_page_number }}">上一页</a> {% endif %} {% if page_obj.has_next %} <a href="/attendance/Node/index.html/?page={{ page_obj.next_page_number }}">下一页</a> {% endif %} <span class="page-current"> 第{{ page_obj.number }}页 ,共{{ page_obj.paginator.num_pages }}页 </span> </span> </div>{% else %}<p>No msgs !!!</p>{%endif%}
0 0
- django viewList 中实现分页功能
- 实现查询ViewList功能
- django 分页功能的实现
- 使用Django实现分页功能
- Django中实现分页
- django使用 Paginator 实现分页功能
- django 1.97 paginator实现分页功能
- django 1.11 自定义分页功能的实现
- django-pure-pagination分页功能的实现
- 【Django插件使用】django-pagination实现页面分页功能
- 修改Django分页类,自定义实现分页功能
- ViewList
- django 分页功能
- django 分页功能
- Django 分页功能
- Django之分页功能
- Django之分页功能
- django 分页功能
- 并查集
- Cookie Session
- 数据结构实验之图论七:驴友计划
- HDU 5617 Jam's maze(dp)
- fatal error C1189: #error: Please use the /MD switch for _AFXDLL builds
- django viewList 中实现分页功能
- 转 struts2中改变struts.xml默认路径 或可能遇到的问题
- 机器人听觉要考虑的噪声消除
- 透彻讲解instancesRespondToSelector与respondsToSelector的区别
- linux下查看网关的命令/DNS
- #9.DHCP服务器搭建
- cuda中pinned memory(page-locked memory)
- 动画层内容
- HTML5 之工作线程