from django.core.paginator import Paginator, Page, PageNotAnInteger, EmptyPage
+
class InfinitePaginator(Paginator):
"""
Paginator designed for cases when it's not important to know how many total
Checks for one more item than last on this page.
"""
try:
- next_item = self.paginator.object_list[
- self.number * self.paginator.per_page]
+ self.paginator.object_list[self.number * self.paginator.per_page]
except IndexError:
return False
return True
return self.paginator.link_template % (self.number - 1)
return None
+
class FinitePaginator(InfinitePaginator):
"""
Paginator for cases when the list of items is already finite.
page_items = self.object_list[:self.per_page]
return FinitePage(page_items, number, self)
+
class FinitePage(InfinitePage):
def has_next(self):
Checks for one more item than last on this page.
"""
try:
- next_item = self.paginator.object_list[self.paginator.per_page]
+ self.paginator.object_list[self.paginator.per_page]
except IndexError:
return False
return True
relative to total objects in the paginator.
"""
## TODO should this holler if you haven't defined the offset?
- return self.paginator.offset
\ No newline at end of file
+ return self.paginator.offset