diff options
author | Nick Pope <nick.pope@flightdataservices.com> | 2020-08-06 11:43:42 +0200 |
---|---|---|
committer | Carlton Gibson <carlton@noumenal.es> | 2020-08-06 12:38:56 +0200 |
commit | 0a306f7da668e53af2516bfad759b52d6c650b69 (patch) | |
tree | b60b7e9b534d95830c6afd1f6bc39d0791d79b25 /docs/ref/paginator.txt | |
parent | f35840c19664fed7b6bc4cf561bf0b6fd1a3b463 (diff) | |
download | django-0a306f7da668e53af2516bfad759b52d6c650b69.tar.gz |
Fixed #25513 -- Extracted admin pagination to Paginator.get_elided_page_range().
Diffstat (limited to 'docs/ref/paginator.txt')
-rw-r--r-- | docs/ref/paginator.txt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/ref/paginator.txt b/docs/ref/paginator.txt index 877d6ba0d8..4cc5483828 100644 --- a/docs/ref/paginator.txt +++ b/docs/ref/paginator.txt @@ -78,9 +78,40 @@ Methods Returns a :class:`Page` object with the given 1-based index. Raises :exc:`InvalidPage` if the given page number doesn't exist. +.. method:: Paginator.get_elided_page_range(number, *, on_each_side=3, on_ends=2) + + .. versionadded:: 3.2 + + Returns a 1-based list of page numbers similar to + :attr:`Paginator.page_range`, but may add an ellipsis to either or both + sides of the current page number when :attr:`Paginator.num_pages` is large. + + The number of pages to include on each side of the current page number is + determined by the ``on_each_side`` argument which defaults to 3. + + The number of pages to include at the beginning and end of page range is + determined by the ``on_ends`` argument which defaults to 2. + + For example, with the default values for ``on_each_side`` and ``on_ends``, + if the current page is 10 and there are 50 pages, the page range will be + ``[1, 2, '…', 7, 8, 9, 10, 11, 12, 13, '…', 49, 50]``. This will result in + pages 4, 5, and 6 to the left of and 8, 9, and 10 to the right of the + current page as well as pages 1 and 2 at the start and 49 and 50 at the + end. + + Raises :exc:`InvalidPage` if the given page number doesn't exist. + Attributes ---------- +.. attribute:: Paginator.ELLIPSIS + + .. versionadded:: 3.2 + + A translatable string used as a substitute for elided page numbers in the + page range returned by :meth:`~Paginator.get_elided_page_range`. Default is + ``'…'``. + .. attribute:: Paginator.count The total number of objects, across all pages. |