Code

Opened 8 years ago

Closed 7 years ago

Last modified 6 years ago

#2576 closed enhancement (wontfix)

[patch] PaginatorPage object

Reported by: SmileyChris Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

class PaginatorPage:
    """
    This class is used to work with a page of a paginator object.
    Pass a paginator object, and a valid page number.
    It uses the same methods as a paginator, except you do not need
    to use a page number.
    """

So it's just a page aware paginator object wrapper.

For example, if you have a paginator object in a view, you can set up a PaginatorPage object (passing the paginator and current page number) and then pass this object directly to your template.

  • It can work in a different base (base-1 is nice to work with at a template level)
  • It can return the next / previous page number

Attachments (1)

paginatorpage.py (2.2 KB) - added by SmileyChris 8 years ago.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by SmileyChris

comment:1 Changed 8 years ago by SmileyChris

I'm thinking perhaps it should default to base 1 too.

i.e. PaginatorPage(paginator, 0, base=1) instead of the current base=0 default

comment:2 Changed 7 years ago by jacob

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

Neat class, but a little too obscure for inclusion in Django. File it away in your bag of tricks, though :)

comment:3 Changed 6 years ago by adrian

Note that this was implemented in [7306].

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.