A Paginator divides a large iterable or QuerySet into smaller pages. This avoids information overload for users and prevents one query from returning an unlimited number of objects. section 4.6.3
A typical paginated view follows a short request-to-template flow:
- Create a Paginator from the object listing and a per-page limit. section 4.6.3
- Read the page number from request.GET, using page 1 when it is absent. section 4.6.3
Paginating musicians
A musicians view orders all musicians by last name, creates Paginator(all_musicians, 2), reads ?page= from the URL, and renders two musicians at a time. The template uses has_previous, has_next, previous_page_number, and next_page_number to show Prev and Next links.
