Page Controls in ListView
Add next/previous links in templates.
Pagination Built In
Good news: ListView can paginate for you. You barely write any code, and Django handles slicing the queryset into pages automatically. 🚀
Set paginate_by
Just add one attribute. Setting paginate_by tells the ListView how many items each page should show.
class ArticleList(ListView):
model = Article
paginate_by = 10All lessons in this course
- The Paginator Class
- Page Controls in ListView
- Writing TestCase and assertions
- The Test Client and Fixtures