BasePaginator
This class provides a base implementation for splitting a list of objects into manageable pages. It handles page validation, supports elided page ranges for compact navigation, and allows for a configurable number of orphan items to be merged into the final page. The class also includes built-in warnings for unordered data sources to ensure consistent pagination results.
Attributes
| Attribute | Type | Description |
|---|---|---|
| ELLIPSIS | string = … | String used to replace omitted page numbers in elided page range generated by paginators, e.g. [1, 2, '…', 5, 6, 7, '…', 9, 10]. |
| default_error_messages | dict | A dictionary containing the default translated error messages for invalid page numbers, minimum page violations, and empty results. |
Constructor
Signature
def BasePaginator(
object_list: list,
per_page: int,
orphans: int = 0,
allow_empty_first_page: boolean = True,
error_messages: dict = null
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| object_list | list | A list, tuple, QuerySet, or other sliceable object with a count() or len() method. |
| per_page | int | The maximum number of items to include on a page, excluding orphans. |
| orphans | int = 0 | The minimum number of items allowed on the last page. |
| allow_empty_first_page | boolean = True | Whether the first page is allowed to be empty. |
| error_messages | dict = null | A dictionary containing custom error messages to override the defaults. |