Django

Code

Ticket #2093 (closed: duplicate)

Opened 2 years ago

Last modified 2 years ago

[patch] Better paginator

Reported by: SmileyChris Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords: paginator patch
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

There's no orhpan feature for the paginator. For example:

22 records, num_per_page=10, orphan=2 --> pages==2, len(self.get_page(1))==12

The paginator should work with lists too.

The patch fixes these and also provides more accurate validation.

Attachments

better_paginator.patch (5.0 kB) - added by SmileyChris on 06/05/06 19:12:35.
better_paginator_with_paginator_page_addition.patch (6.2 kB) - added by SmileyChris on 06/12/06 17:08:37.
PaginatorPage? object - page aware ObjectPaginator? wrapper
better_paginator_with_paginator_page_addition.2.patch (7.3 kB) - added by SmileyChris on 08/13/06 23:32:35.

Change History

06/05/06 19:12:35 changed by SmileyChris

  • attachment better_paginator.patch added.

06/05/06 22:54:16 changed by anonymous

  • type changed from defect to enhancement.

06/12/06 17:07:48 changed by SmileyChris

I have another useful addition to this patch, up to the Django developers whether it should be added. better_paginator.patch is still fine, this new one has those enhancements + a new object in paginator.py:

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.

06/12/06 17:08:37 changed by SmileyChris

  • attachment better_paginator_with_paginator_page_addition.patch added.

PaginatorPage? object - page aware ObjectPaginator? wrapper

07/14/06 09:40:27 changed by germish@gmail.com

  • keywords set to paginator patch.
  • component changed from Admin interface to Core framework.

I like the patch. I haven't tested it, but by looking at the code it does seem to improve upon what's already there. In addition, it addresses my enhancement ticket #2352.

Though, I am not sure the PaginatorPage? class would be necessary.

07/14/06 18:54:33 changed by SmileyChris

It's definately not necessary and is a seperate enhancement, but I have found it useful.

When you have a batch of objects, it is a lot easier dealing with a PaginatorPage? object than a Paginator object in the template. I mean why should the template have to know which page it's on when getting the correct batch? It shouldn't - therefore this helps keep that logic in the view while still providing all the useful Paginator methods to the template author.

08/13/06 23:32:35 changed by SmileyChris

  • attachment better_paginator_with_paginator_page_addition.2.patch added.

08/15/06 07:30:38 changed by mtredinnick

Could you split this up into two patches please and move the new functionality (the PaginatorPage class) to a new ticket. I am not too enthused (at least, not yet) about the PaginatorPage without it undergoing a bit more work, but the orphan/widow stuff looks pretty straightforward. It's just hard to address two completely separate features in one ticket (the fact that they both talk about pagination is just a coincidence). So if you could split it up and move part of it to a new ticket, then we can handle each part separately.

08/20/06 18:46:32 changed by SmileyChris

  • status changed from new to closed.
  • resolution set to duplicate.

Split into two tickets at Malcom's request.

#2575 - orphans and general additions to paginator #2576 - new PaginatorPage object


Add/Change #2093 ([patch] Better paginator)




Change Properties
Action