1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Paginator._get_page hook

This allows for Paginator subclasses to easily override the Page class
that gets used.

Took the opportunity to also do some non-invasive PEP8 tidying of the
paginator module.
This commit is contained in:
Chris Beaven
2012-11-21 14:58:14 +13:00
parent 8fdb28219d
commit fbfa654a15
3 changed files with 67 additions and 7 deletions

View File

@@ -0,0 +1,20 @@
from django.core.paginator import Paginator, Page
class ValidAdjacentNumsPage(Page):
def next_page_number(self):
if not self.has_next():
return None
return super(ValidAdjacentNumsPage, self).next_page_number()
def previous_page_number(self):
if not self.has_previous():
return None
return super(ValidAdjacentNumsPage, self).previous_page_number()
class ValidAdjacentNumsPaginator(Paginator):
def _get_page(self, *args, **kwargs):
return ValidAdjacentNumsPage(*args, **kwargs)