python - django 的分页器中的孤儿是什么意思?

标签 python django pagination

我找到了/django/core/paginator.py 源代码:

class Paginator(object):
def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True):
    self.object_list = object_list
    self.per_page = int(per_page)
    self.orphans = int(orphans)
    self.allow_empty_first_page = allow_empty_first_page
    self._num_pages = self._count = None

orphans 属性是什么意思?

最佳答案

来自docs

orphans
The minimum number of items allowed on the last page, defaults to zero. Use this when you don’t want to have a last page with very few items. If the last page would normally have a number of items less than or equal to orphans, then those items will be added to the previous page (which becomes the last page) instead of leaving the items on a page by themselves. For example, with 23 items, per_page=10, and orphans=3, there will be two pages; the first page with 10 items and the second (and last) page with 13 items.

关于python - django 的分页器中的孤儿是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18669702/

相关文章:

python - 来自模型的 django url

python - django 在日期范围内按日期时间过滤

python - 提取 Django 管理命令中的常用功能

python - 如何在 Django 中结合过滤和分页?

mysql - 优化分页的 DISTINCT/LIMIT MySQL 查询

python - 使用 Django 作为 Cappuccino 的后端

python - 使用不同的 python 安装 virtualenv 时断言错误

python - 如何在没有root权限的情况下部署nginx?

python - Django如何重写 'get_or_create'来创建父对象(如果它不存在)

mysql - 分页和表单标签问题