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

This entry was posted in django, en, geek, programacion and tagged , . Bookmark the permalink.

One Response to Using object_list generic view for pagination in Django

  1. Anonymous says:

    thanks for the info!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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