Looking for something that could let you split your data across multiple pages in your Django application ?
Want only specified number of results on every page and thus, have a list of pages to traverse with next or previous links ?
So, here you are at the right place to get exactly what you are looking for.
What comes to your rescue is Pagination.
Django provides a few classes that help you manage paginated data – that is, data that’s split across several pages, with “Previous/Next” links.
These classes live in django/core/paginator.py.
Paginator takes 2 arguments as :
p = paginator( query_set or list, limit)
The first argument consists of the objects or the lists or queryset you want to display across the pages. The second argument is the number of items you’d like to have on each page.
Don’t forget to import the same, before using, as :
from django.core.paginator import Paginator
With this, you need a few changes in the template and you are done !
Here’s a detailed example of the same : Pagination
Happy paginating ! 🙂