module documentation

Pagination serializers determine the structure of the output that should be used for paginated responses.

Class BasePagination Undocumented
Class CursorPagination The cursor pagination implementation is necessarily complex. For an overview of the position/offset style we use, see this post: https://cra.mr/2011/03/08/building-cursors-for-the-disqus-api
Class LimitOffsetPagination A limit/offset based style. For example:
Class PageNumberPagination A simple page number based style that supports page numbers as query parameters. For example:
Constant PAGE_BREAK Undocumented
Variable Cursor Undocumented
Variable PageLink Undocumented
Function _divide_with_ceil Returns 'a' divided by 'b', with any remainder rounded up.
Function _get_displayed_page_numbers This utility function determines a list of page numbers to display. This gives us a nice contextually relevant set of page numbers.
Function _get_page_links Given a list of page numbers and `None` page breaks, return a list of `PageLink` objects.
Function _positive_int Cast a string to a strictly positive integer.
Function _reverse_ordering Given an order_by tuple such as `('-created', 'uuid')` reverse the ordering and return a new tuple, eg. `('created', '-uuid')`.
PAGE_BREAK = (source)

Undocumented

Value
PageLink(url=None, number=None, is_active=False, is_break=True)

Undocumented

PageLink = (source)

Undocumented

def _divide_with_ceil(a, b): (source)

Returns 'a' divided by 'b', with any remainder rounded up.

def _get_displayed_page_numbers(current, final): (source)

This utility function determines a list of page numbers to display. This gives us a nice contextually relevant set of page numbers. For example: current=14, final=16 -> [1, None, 13, 14, 15, 16] This implementation gives one page to each side of the cursor, or two pages to the side when the cursor is at the edge, then ensures that any breaks between non-continuous page numbers never remove only a single page. For an alternative implementation which gives two pages to each side of the cursor, eg. as in GitHub issue list pagination, see: https://gist.github.com/tomchristie/321140cebb1c4a558b15

def _get_page_links(page_numbers, current, url_func): (source)

Given a list of page numbers and `None` page breaks, return a list of `PageLink` objects.

def _positive_int(integer_string, strict=False, cutoff=None): (source)

Cast a string to a strictly positive integer.

def _reverse_ordering(ordering_tuple): (source)

Given an order_by tuple such as `('-created', 'uuid')` reverse the ordering and return a new tuple, eg. `('created', '-uuid')`.