Paging#

Two view mixins live in richy.core.views: one for paginating a ListView automatically, one for paginating any arbitrary queryset / iterable.

Both render through the shared _paging.pug template (see Includables).

ModelPaginatorMixin#

Drop-in mixin for a Django ListView that adds a pages and a paginator context variable – the _paging.pug include then renders the pager UI. Default page size is 20; override paginate_by on the view to change it.

class richy.core.views.ModelPaginatorMixin[source]#

Bases: object

Provides paginator for ListViews based on model which template includes _paging.pug template.

ModelPaginatorMixin.get_context_data(**kwargs)[source]#

Adds pages and paginator context variables.

PaginatorMixin#

Lower-level mixin for paginating an arbitrary list / queryset (not necessarily the one driving a ListView). Exposes get_paginator(), which returns (page, elided_page_range) – a tuple the view passes to the template.

class richy.core.views.PaginatorMixin[source]#

Bases: object

PaginatorMixin.get_paginator(object_list, per_page=20, get_attr_name='page')[source]#

Creates paginator object, paginates the given object_list and also returns elided page range.

Parameters:
  • object_list (list) – QuerySet or list of object to paginate.

  • per_page (int) – Number of items per page.

  • get_attr_name – Name of GET attribute which carries the page number.

Returns:

Returns Page object and list of elided pages (for paging in template).

Return type:

tuple