AsyncPage
This class represents a single page of results within an asynchronous pagination system. It provides asynchronous methods to navigate between pages, calculate result indices, and retrieve the underlying object list as a sequence. Users must await the object list retrieval before performing standard sequence operations like indexing or length checks.
Attributes
| Attribute | Type | Description |
|---|---|---|
| object_list | async_iterator or list | The collection of items on this page, which may be an asynchronous iterator or a list after being awaited via aget_object_list. |
| number | int | The 1-based page number representing the current position within the paginator. |
| paginator | [AsyncPaginator](asyncpaginator.md?sid=django_core_paginator_asyncpaginator) | The paginator instance that created this page, used to access metadata like total page counts and validation logic. |
Constructor
Signature
def AsyncPage(
object_list: Any,
number: int,
paginator: [AsyncPaginator](asyncpaginator.md?sid=django_core_paginator_asyncpaginator)
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| object_list | Any | The collection of objects for the current page, which may be an asynchronous iterator or a list. |
| number | int | The 1-based page number for this page instance. |
| paginator | [AsyncPaginator](asyncpaginator.md?sid=django_core_paginator_asyncpaginator) | The paginator object that created this page. |
Methods
aget_object_list()
@classmethod
def aget_object_list() - > list
Returns self.object_list as a list. This method must be awaited before AsyncPage can be treated as a sequence of self.object_list.
Returns
| Type | Description |
|---|---|
list | The fully resolved list of objects for the current page. |
ahas_next()
@classmethod
def ahas_next() - > boolean
Determines if there is a subsequent page available after the current one.
Returns
| Type | Description |
|---|---|
boolean | True if the current page number is less than the total number of pages, otherwise False. |
ahas_previous()
@classmethod
def ahas_previous() - > boolean
Determines if there is a preceding page available before the current one.
Returns
| Type | Description |
|---|---|
boolean | True if the current page number is greater than 1, otherwise False. |
ahas_other_pages()
@classmethod
def ahas_other_pages() - > boolean
Checks for the existence of any other pages, either before or after the current one.
Returns
| Type | Description |
|---|---|
boolean | True if either a next or a previous page exists. |
anext_page_number()
@classmethod
def anext_page_number() - > integer
Calculates and validates the page number for the next page.
Returns
| Type | Description |
|---|---|
integer | The validated integer representing the next page number. |
aprevious_page_number()
@classmethod
def aprevious_page_number() - > integer
Calculates and validates the page number for the previous page.
Returns
| Type | Description |
|---|---|
integer | The validated integer representing the previous page number. |
astart_index()
@classmethod
def astart_index() - > integer
See Page.start_index().
Returns
| Type | Description |
|---|---|
integer | The 1-based index of the first object on this page relative to the entire result set. |
aend_index()
@classmethod
def aend_index() - > integer
See Page.end_index().
Returns
| Type | Description |
|---|---|
integer | The 1-based index of the last object on this page relative to the entire result set. |