标签:cts tor tin utf-8 link back class 没有 模板
from django.core.paginator import Paginator p=Paginator(report.objects.order_by("-endtime"),20) #对数据进行分页,默认每页20条数据 pagenums=p.num_pages
<html lang="en"> <head> <meta charset="UTF-8"> <title>index</title> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" > <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"> <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <ul class="pagination" > {% if pagenum > 1%} <li><a href="{% url ‘reports‘ %}?pagenum={{ pagenum|add:-1 }}">«</a></li> {% else %} <li><a href="">«</a></li> {% endif %} {% for currentpagenum in reportinfos.pagenums%} {% if currentpagenum == pagenum %} <li><a href="{% url ‘reports‘ %}?pagenum={{ currentpagenum }}" style="background-color: #5bc0de">{{ currentpagenum }}</a></li> {% else %} <li><a href="{% url ‘reports‘ %}?pagenum={{ currentpagenum }}">{{ currentpagenum }}</a></li> {% endif %} {% endfor %} {% if pagenum < reportinfos.maxpagenum %} <li><a href="{% url ‘reports‘ %}?pagenum={{ pagenum|add:1 }}">»</a></li> {% else %} <li><a href="">»</a></li> {% endif %} </ul> </body> </html>
标签:cts tor tin utf-8 link back class 没有 模板
原文地址:http://www.cnblogs.com/meitian/p/6912702.html