Code

#19165 closed New feature (invalid)

add first and last page to paginator

Reported by: ciro.santilli@… Owned by: nobody
Component: Core (Other) Version: 1.4
Severity: Normal Keywords: paginator, last page, first page
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Hi,

If it does not exist, add a first/last page method to the Page object returned by django.core.paginator import Paginator,
so that web pages can easily do first/last page links.

If it exists, add it to the docs at:

https://docs.djangoproject.com/en/dev/topics/pagination/#django.core.paginator.Page

Attachments (0)

Change History (3)

comment:1 Changed 21 months ago by lrekucki

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

Both the first and last page can be accessed easily through the paginator:

first_page = paginator.page(1)
last_page = paginator.page(paginator.num_pages)

IMHO, there is no need for anything like first_page_number as it's always 1 and page.last_page_number doesn't save much compared to page.paginator.num_pages. But maybe I'm missing something.

comment:2 Changed 21 months ago by Ciro Duran Santilli <ciro.santilli@…>

Aw, should have read better the tutorial, I hadn't seen that the Page object (which is what is usually passed to templates) has a Paginator field.

In this case, we can just write:

page.paginator.num_pages

for the last page.

So I agree adding more fields to the Page object would be a minor improvement.

This ticket can be closed on my part.

comment:3 Changed 21 months ago by claudep

  • Resolution set to invalid
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.