Skip to content

adjunct.pagination

Pagination support.

InvalidPageError

Bases: Exception

Raised when an invalid page is requested.

paginator(page_num, max_page, buffer_size=3)

Generate a sequence of page numbers, giving the pages at the beginning and end, and around the current page, with a number of buffer pages on each side of both. Omitted pages in the sequence are elided into a None.

Parameters:

Name Type Description Default
page_num int

the current page

required
max_page int

the maximum page number to create a link to

required
buffer_size int

the number of page links to generate on each side of the current page

3

Yields:

Type Description
int | None

A page number, or None to indicate an elided series of pages.