summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorwookkl <wjddnr315@gmail.com>2025-03-12 00:53:04 +0900
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-03-12 09:22:44 +0100
commit2ae3044d9d4dfb8371055513e440e0384f211963 (patch)
tree771c0a6340bd0eb8a05c608ae2919652b16ce876 /docs
parent0ebea6e5c07485a36862e9b6e2be18d1694ad2c5 (diff)
Fixed #35945 -- Added async interface to Paginator.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/paginator.txt46
-rw-r--r--docs/releases/6.0.txt8
2 files changed, 54 insertions, 0 deletions
diff --git a/docs/ref/paginator.txt b/docs/ref/paginator.txt
index 03084e5d40..d5b5b0f30e 100644
--- a/docs/ref/paginator.txt
+++ b/docs/ref/paginator.txt
@@ -161,6 +161,30 @@ Attributes
A 1-based range iterator of page numbers, e.g. yielding ``[1, 2, 3, 4]``.
+``AsyncPaginator`` class
+========================
+
+.. versionadded:: 6.0
+
+.. class:: AsyncPaginator(object_list, per_page, orphans=0, allow_empty_first_page=True, error_messages=None)
+
+ Asynchronous version of :class:`Paginator`.
+
+ ``AsyncPaginator`` has the same attributes and signatures as
+ :class:`Paginator`, with the following exceptions:
+
+ * The attribute :attr:`.Paginator.count` is supported as an asynchronous
+ method ``AsyncPaginator.acount()``.
+ * The attribute :attr:`.Paginator.num_pages` is supported as an
+ asynchronous method ``AsyncPaginator.anum_pages()``.
+ * The attribute :attr:`.Paginator.page_range` is supported as an
+ asynchronous method ``AsyncPaginator.apage_range()``.
+
+ ``AsyncPaginator`` has asynchronous versions of the same methods as
+ :class:`Paginator`, using an ``a`` prefix - for example, use
+ ``await async_paginator.aget_page(number)`` rather than
+ ``paginator.get_page(number)``.
+
``Page`` class
==============
@@ -226,6 +250,28 @@ Attributes
The associated :class:`Paginator` object.
+``AsyncPage`` class
+===================
+
+.. versionadded:: 6.0
+
+.. class:: AsyncPage(object_list, number, paginator)
+
+ Asynchronous version of :class:`Page`.
+
+ ``AsyncPage`` has the same attributes and signatures as :class:`Page`, as
+ well as asynchronous versions of all the same methods, using an ``a``
+ prefix - for example, use ``await async_page.ahas_next()`` rather than
+ ``page.has_next()``.
+
+ ``AsyncPage`` has the following additional method:
+
+ .. method:: AsyncPage.aget_object_list()
+
+ Returns ``AsyncPage.object_list`` as a list. This method must be
+ awaited before ``AsyncPage`` can be treated as a sequence of
+ ``AsyncPage.object_list``.
+
Exceptions
==========
diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt
index 9e74856664..c604638deb 100644
--- a/docs/releases/6.0.txt
+++ b/docs/releases/6.0.txt
@@ -199,6 +199,14 @@ Models
:ref:`a forced update <ref-models-force-insert>` results in no affected rows,
instead of a generic :exc:`django.db.DatabaseError`.
+Pagination
+~~~~~~~~~~
+
+* The new :class:`~django.core.paginator.AsyncPaginator` and
+ :class:`~django.core.paginator.AsyncPage` provide async implementations of
+ :class:`~django.core.paginator.Paginator` and
+ :class:`~django.core.paginator.Page` respectively.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~