Django

Code

Ticket #2367 (new)

Opened 2 years ago

Last modified 11 months ago

[patch] pagination for date based generic views

Reported by: andrewg@weblinc.com Assigned to: nobody
Milestone: Component: Generic views
Version: SVN Keywords:
Cc: paolo@php3.it, yatiohi@ideopolis.gr Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

Description

Date based views do not have pagination. This patch adds pagination to the archive_day, archive_week, archive_month generic views. archive_index does not require pagination because of the num_latest argument.

Attachments

date_based_paginate.diff (8.8 kB) - added by apgwoz@gmail.com on 07/17/06 14:01:52.
date_based_pagination.diff (11.8 kB) - added by paolo@php3.it on 03/16/07 18:52:15.
pagination for each date_based
generic_views_pagination.diff (15.2 kB) - added by paolo@php3.it on 03/20/07 09:00:48.
5992-pagination-for-datebased-generic-views.diff (16.4 kB) - added by Øyvind Saltvik <oyvind@saltvik.no> on 08/22/07 15:57:49.
removed Http404 dependency in pagination.py, reraised InvalidPage?, wrapped compute_pagination in a try except, use count instead of len on queryset.
django_pagination.diff (10.1 kB) - added by Tyler <tyler@tylers.org> on 05/05/08 14:48:31.
The previous patch uses the deprecated ObjectPaginator? class and changes paginator.py. This patch changes only date_based.py and uses the newer interface as defined in list_detail.py's object_list method.
django_pagination.2.diff (10.1 kB) - added by Tyler <tyler@tylers.org> on 05/05/08 15:06:45.
small diff fix

Change History

07/17/06 14:01:52 changed by apgwoz@gmail.com

  • attachment date_based_paginate.diff added.

(follow-up: ↓ 3 ) 10/01/06 19:16:06 changed by mtredinnick

If we commit this, I think we should add pagination to archive_index as well, since num_latest does not help you view "the second page of the latest headlines".

02/08/07 22:39:32 changed by SmileyChris

  • stage changed from Unreviewed to Design decision needed.

(in reply to: ↑ 1 ) 02/09/07 08:45:18 changed by anonymous

Replying to mtredinnick:

If we commit this, I think we should add pagination to archive_index as well, since num_latest does not help you view "the second page of the latest headlines".

I agree. My original logic in that was flawed. Pagination should exist in all generic date based views.

03/16/07 18:49:58 changed by paolo@php3.it

  • cc set to paolo@php3.it.

My patch adds pagination capabilities to each date based generic view, except object_detail.

If it will be accepted for checkin I'll be glad to add a patch to update the documentation as well.

03/16/07 18:52:15 changed by paolo@php3.it

  • attachment date_based_pagination.diff added.

pagination for each date_based

03/17/07 00:09:43 changed by Gary Wilson <gary.wilson@gmail.com>

  • needs_better_patch set to 1.

I like the factoring out of the common elements. Why not put everything in the Paginator object though, something along the idea of the patch attached to #1374? Also, whatever we do, it should be done for all the generic views, not just the date_based.

03/17/07 03:56:16 changed by paolo@php3.it

Next week I'll work on that.

What I can do is to move inside Paginator the function for queryset computation and context updating. Then I'll change list_detail generic views to use this code.

You say that it should be done for *all the generic views*, *not just the date_based*. But after the new patch, both date_based and list_detail will use the same code for pagination. Simple generic views and CRUD shouldn't have the needing of pagination, isn't it?

03/17/07 20:08:29 changed by Gary Wilson <gary.wilson@gmail.com>

By all generic views, I meant all the ones where it makes sense, but I guess besides the date_based views, object_list is the only other one that makes sense.

03/20/07 08:58:52 changed by paolo <paolo@php3.it>

Searching Django's related groups for more info about pagination I saw there have been a lot of discussions about "how Paginator should be" (to cite one, http://groups.google.com/group/django-users/browse_frm/thread/6963a1fdb6473352/d4622e25fc54bade). Even so, Paginator class hasn't changed in time (except for orphans handling), probably because features that actually provides are ok for the most of people. Thus I'd prefer not to change Paginator's code (that's working well btw).

In the light of what said, the latest patch (generic_views_pagination.diff) adds a new function at paginator module leaving Paginator class untouched. Then, it changes date_based and list_detail generic views to using this function to retrieve the paginated queryset and update the context with pagination variables.

Any chance anyone would comment and/or test the patch?

Thanks.

03/20/07 09:00:48 changed by paolo@php3.it

  • attachment generic_views_pagination.diff added.

03/20/07 14:27:55 changed by paolo@php3.it

Don't consider the last patch I uploaded, it has at least two issues, introduces a dependency on django.http and uses allow_empty which is not defined there. Et voilà!

08/22/07 15:57:49 changed by Øyvind Saltvik <oyvind@saltvik.no>

  • attachment 5992-pagination-for-datebased-generic-views.diff added.

removed Http404 dependency in pagination.py, reraised InvalidPage?, wrapped compute_pagination in a try except, use count instead of len on queryset.

08/22/07 16:01:30 changed by Øyvind Saltvik <oyvind@saltvik.no>

Added a patch that fixes some of the issues mentioned.

Added a page argument to object_detail that is passed to context.

11/30/07 15:40:49 changed by jacob

  • stage changed from Design decision needed to Accepted.

01/10/08 06:24:43 changed by ctrochalakis

  • cc changed from paolo@php3.it to paolo@php3.it, yatiohi@ideopolis.gr.

05/05/08 14:48:31 changed by Tyler <tyler@tylers.org>

  • attachment django_pagination.diff added.

The previous patch uses the deprecated ObjectPaginator? class and changes paginator.py. This patch changes only date_based.py and uses the newer interface as defined in list_detail.py's object_list method.

05/05/08 15:06:45 changed by Tyler <tyler@tylers.org>

  • attachment django_pagination.2.diff added.

small diff fix


Add/Change #2367 ([patch] pagination for date based generic views)




Change Properties
Action