Using object_list generic view for pagination in Django

Whenever I want to display a list of items I’ll need pagination, calculate first page, next page, total pages, current page, previous page, etc.

Although Django comes with pretty good pagination helpers, I’ve found that using the list_detail.object_list generic view hanles this very nicely :)

So whenever I want to display a list, I will return an object_list generic view instead of a HttpResponse object or a render_to_response call.

This came in pretty handy when helping Jason Broyles refactor some pagination code

1 Comment so far

  1. Anonymous

    April 7th, 2009

    thanks for the info!


Add yours

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>