Ticket #1795: paginator.py.diff
File paginator.py.diff, 1.0 KB (added by , 19 years ago) |
---|
-
core/paginator.py
17 17 def __init__(self, query_set, num_per_page): 18 18 self.query_set = query_set 19 19 self.num_per_page = num_per_page 20 self._hits, self._pages =None, None20 self._hits, self._pages, self._page_range = None, None, None 21 21 self._has_next = {} # Caches page_number -> has_next_boolean 22 22 23 23 def get_page(self, page_number): … … 63 63 if self._pages is None: 64 64 self._pages = int(ceil(self.hits / float(self.num_per_page))) 65 65 return self._pages 66 67 def _get_page_range(self): 68 """Returns a 1-based range of pages for iterating through within a template for loop.""" 69 if self._page_range is None: 70 self._page_range = range(1, self._pages + 1) 71 return self._page_range 66 72 67 73 hits = property(_get_hits) 68 74 pages = property(_get_pages) 75 page_range = property(_get_page_range)