1 django自带分页
1.1 分页模板
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7-dist/css/bootstrap.css"> </head> <body> <p>用户信息</p> <table class="table"> <thead> <tr> <th>id</th> <th>name</th> <th>age</th> <th>type</th> </tr> </thead> <tbody> {% for row in current_page_obj %} <tr> <td>{{ row.id }}</td> <td>{{ row.name }}</td> <td>{{ row.age }}</td> <td>{{ row.ut.title }}</td> </tr> {% endfor %} </tbody> </table> <div> {% if current_page_obj.has_previous %} <a href="/fenye/?page={{ current_page_obj.previous_page_number }}">上一页</a> {% endif %} {% for page in current_page_obj.paginator.page_range %} <a href="/fenye/?page={{ page }}">{{ page }}</a> {% endfor %} {% if current_page_obj.has_next %} <a href="/fenye/?page={{ current_page_obj.next_page_number }}">下一页</a> {% endif %} </div> </body> </html>