Opened 9 years ago

Closed 9 years ago

#7166 closed (invalid)

Need to document paging variables added to template context by object_list

Reported by: mikechambers Owned by: nobody
Component: Generic views Version: master
Severity: Keywords: documentation
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The django.views.generic.list_detail.object_list api should be documented to include which pagination name / value pairs are added the templates context.

http://www.djangoproject.com/documentation/generic_views/

APIs include:

The properties (from the code documentation are):

is_paginated : are the results paginated?

results_per_page : number of objects per page (if paginated)

has_next : is there a next page?

has_previous : is there a prev page?

page : the current page

next : the next page

previous : the previous page

pages : number of pages, total

hits : number of objects, total

last_on_page : the result number of the last of object in the object_list (1-indexed)

first_on_page : the result number of the first object in the object_list (1-indexed)

page_range : A list of the page numbers (1-indexed).

This information does not appear to be available in the docs anywhere which makes implementing paging more difficult than it should be.

Attachments (1)

7166.patch (1.3 KB) - added by mikechambers 9 years ago.
Patch to include documentation on pagination variables exposed in template

Download all attachments as: .zip

Change History (5)

comment:1 Changed 9 years ago by James Bennett

Resolution: worksforme
Status: newclosed

It links to the notes on pagination, which in turn link to a full example. I'm not sure there's a need for more than that.

comment:2 in reply to:  1 Changed 9 years ago by mikechambers

Replying to ubernostrum:

It links to the notes on pagination, which in turn link to a full example. I'm not sure there's a need for more than that.

That example is not useful as not all of those variables are available in the template, which then leads to a bunch of trial and error to figure out what can be used.

If you are a new user, this is really confusing, and again, leads to a bunch of trial and error to see what is exposed.

Changed 9 years ago by mikechambers

Attachment: 7166.patch added

Patch to include documentation on pagination variables exposed in template

comment:3 Changed 9 years ago by mikechambers

Has patch: set
Resolution: worksforme
Status: closedreopened

I have included a patch to the docs. Please consider including as I think it would make it much easier for new users to learn how to implement pagination.

comment:4 Changed 9 years ago by anonymous

Resolution: invalid
Status: reopenedclosed

Please read documentation carefully - object_list pagination already documented under "Template context": http://www.djangoproject.com/documentation/generic_views/#list-detail-generic-views
And template variables which you are trying to redocument are deprecated anyway.

Note: See TracTickets for help on using tickets.
Back to Top