Code

Opened 6 years ago

Closed 6 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 6 years ago.
Patch to include documentation on pagination variables exposed in template

Download all attachments as: .zip

Change History (5)

comment:1 follow-up: Changed 6 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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 6 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 6 years ago by mikechambers

Patch to include documentation on pagination variables exposed in template

comment:3 Changed 6 years ago by mikechambers

  • Has patch set
  • Resolution worksforme deleted
  • Status changed from closed to reopened

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 6 years ago by anonymous

  • Resolution set to invalid
  • Status changed from reopened to closed

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.

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.