O'Reilly logo

Web Development with Django Cookbook - Second Edition by Aidas Bendoraitis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Managing paginated lists

If you have dynamically changing lists of objects or the amount of them is greater than 30, you will surely need pagination for the list. With pagination, instead of the full QuerySet, you provide a fraction of the dataset that is limited to a specific amount per page and you will also show the links to get to the other pages of the list. Django has classes to manage the paginated data, and we will see how to do that in this recipe for the example provided in the previous recipe.

Getting ready

Let's start with the forms and views of the movies app from the Filtering object lists recipe.

How to do it…

To add pagination to the list view of the movies, follow these steps:

  1. First, import the necessary pagination classes from Django. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required