mirror of
https://github.com/django/django.git
synced 2024-11-29 22:56:46 +01:00
fbfa654a15
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.
21 lines
559 B
Python
21 lines
559 B
Python
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)
|