18.4.4 Extending Pagination Behavior Further

One of the key advantages of our mixin, and the way we are extending GCBV behavior is that it makes it easy to extend behavior across our site. For instance, we might decide to help users navigate pagination by adding first and last links to our pages. Because we’ve adhered to DRY, we only need to make changes in one Python class and one template.

We can start by modifying PageLinksMixin to generate the first and last links for us, as shown in Example 18.15.

Example 18.15: Project Code

organizer/utils.py in 439b4e2f3c

 1   class PageLinksMixin:  2       page_kwarg = 'page'  .       ...  9       def first_page(self, page): 10           # don't show on first page 11            ...

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.