当前位置: 首页>>代码示例>>Python>>正文


Python Paginator.get_page_numbers方法代码示例

本文整理汇总了Python中the_tale.common.utils.pagination.Paginator.get_page_numbers方法的典型用法代码示例。如果您正苦于以下问题:Python Paginator.get_page_numbers方法的具体用法?Python Paginator.get_page_numbers怎么用?Python Paginator.get_page_numbers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在the_tale.common.utils.pagination.Paginator的用法示例。


在下文中一共展示了Paginator.get_page_numbers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from the_tale.common.utils.pagination import Paginator [as 别名]
# 或者: from the_tale.common.utils.pagination.Paginator import get_page_numbers [as 别名]
    def index(self, page=None, place=None):

        records_query = Record.objects.all()

        if place is not None:
            records_query = records_query.filter(actors__place_id=place.id)

        url_builder = UrlBuilder(reverse('game:chronicle:'), arguments={'place': place.id if place else None})

        index_filter = IndexFilter(url_builder=url_builder, values={'place': place.id if place else None})

        records_count = records_query.count()

        if page is None:
            page = Paginator.get_page_numbers(records_count, chronicle_settings.RECORDS_ON_PAGE)
            if page == 0: page = 1
        page = int(page) - 1

        paginator = Paginator(page, records_count, chronicle_settings.RECORDS_ON_PAGE, url_builder, inverse=True)

        if paginator.wrong_page_number:
            return self.redirect(paginator.last_page_url, permanent=False)

        record_from, record_to = paginator.page_borders(page)

        records = [ RecordPrototype(record) for record in records_query.select_related().order_by('created_at', 'created_at_turn')[record_from:record_to]]

        records = list(reversed(records))

        return self.template('chronicle/index.html',
                             {'records': records,
                              'place': place,
                              'paginator': paginator,
                              'index_filter': index_filter,
                              'url_builder': url_builder} )
开发者ID:Alkalit,项目名称:the-tale,代码行数:37,代码来源:views.py


注:本文中的the_tale.common.utils.pagination.Paginator.get_page_numbers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。