14.4 Paginating the Startup List Webpage
With a basic understanding of the Paginator
class, we can turn to our startup list webpage and paginate our list. The goal is to allow pagination via the query part of the URL, resulting in http://site.django-unleashed.com/startup/?page=2
, for example.
Before we can jump directly into using Pagination
and Page
, I am going to opt to switch the Startup
list page from a function view into a class-based view (CBV). While this is by no means necessary, it will make my life easier in the long run.
We start by replacing the function view with the class shown in Example 14.19.
organizer/views.py
in f0f3d8de64
95 class StartupList(View): 96 template_name ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.