Pagination¶
get_page
¶
- djem.pagination.get_page(number, object_list, per_page=None, **kwargs)[source]¶
New in version 0.5.
A simple wrapper around a Django
Paginator
that immediately invokes itspage()
method and returns aPage
object.number
is the number of the page to retrieve, as a 1-based index. If the given value is not an integer, or it is less than1
, it is treated as1
. If it is greater than the total number of pages, it is treated asPaginator.num_pages
.object_list
is the sequence of items from which to retrieve the specified page - as a list, tuple,QuerySet
or any other sliceable object with acount()
or__len__()
method.per_page
is the number of results to be included in each page. Not required ifDJEM_DEFAULT_PAGE_LENGTH
has been defined.All other keyword arguments of the
Paginator
constructor are also accepted and passed through to thePaginator
instance created internally.
See also
DJEM_DEFAULT_PAGE_LENGTH
The setting for controlling the default value of the
per_page
argument.paginate
A templatetag for rendering a block of pagination links based on a given
Page
object.