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>
View Code

相关文章:

  • 2022-01-19
  • 2021-11-18
  • 2022-01-31
  • 2021-05-29
  • 2021-07-08
  • 2022-02-01
  • 2021-12-26
  • 2021-08-24
猜你喜欢
  • 2021-10-08
  • 2021-08-16
  • 2021-07-19
  • 2021-12-13
  • 2021-11-12
  • 2021-08-18
  • 2021-10-15
相关资源
相似解决方案