Code

Opened 6 years ago

Closed 3 years ago

#6860 closed New feature (wontfix)

Improvements for the new paginator

Reported by: Alberto García Hierro <fiam@…> Owned by: nobody
Component: Core (Other) Version: master
Severity: Normal Keywords: paginator
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

This patch adds methods for storing the base_url and retrieving it, displaying the page list as ul or div (taking the current page into account) as well as for obtaining the links for the previous and next pages. I've not included any documentation, because I want to get some feedback about the code itself before writing any doc.

Attachments (2)

0005-Improve-the-new-paginator.diff (6.1 KB) - added by Alberto García Hierro <fiam@…> 6 years ago.
0005-Improve-the-new-paginator.2.diff (5.9 KB) - added by Alberto García Hierro <fiam@…> 6 years ago.
Improved version of the patch

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by Alberto García Hierro <fiam@…>

Changed 6 years ago by Alberto García Hierro <fiam@…>

Improved version of the patch

comment:1 Changed 6 years ago by programmerq

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

This looks useful, and would probably clean up views that use the paginator.
The patch applies beautifully to current trunk.

comment:3 Changed 3 years ago by julien

  • Needs tests set
  • Patch needs improvement set

This seems useful but the patch is old and needs to be updated. Also needs tests.

comment:4 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 3 years ago by carljm

  • Easy pickings unset
  • UI/UX unset

Discussion with Alex: the PageList object hardcodes a bunch of HTML in Python strings, which is not ok. The page_or_404 method and the base_url, next url, previous url stuff break the conceptual boundary of the Paginator object, so it no longer just paginates a sequence of objects, but now also has (rudimentary) knowledge of how URLs are constructed to reach those objects.

These problems are solved more cleanly by third-party packages such as django-pagination, that wrap more sophisticated URL logic and display utilities around the core Paginator rather than extending it in a way that breaks its conceptual simplicity. And it makes sense to leave such packages outside core, because how page numbering is displayed and how pagination URLs are handled is a matter of preference that will vary between projects.

comment:6 Changed 3 years ago by carljm

  • Resolution set to wontfix
  • 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.