Ticket #6997: paginator2.diff
File paginator2.diff, 1.4 KB (added by , 16 years ago) |
---|
-
django/core/paginator.py
53 53 def _get_num_pages(self): 54 54 "Returns the total number of pages." 55 55 if self._num_pages is None: 56 hits = self.count - 1 - self.orphans 57 if hits < 1: 58 hits = 0 59 if hits == 0 and not self.allow_empty_first_page: 56 if self.count - self.orphans <= 0 and not self.allow_empty_first_page: 60 57 self._num_pages = 0 61 58 else: 59 hits = self.count - 1 - self.orphans 60 if hits < 0: 61 hits = 0 62 62 self._num_pages = hits // self.per_page + 1 63 63 return self._num_pages 64 64 num_pages = property(_get_num_pages) -
tests/modeltests/pagination/models.py
140 140 >>> p.end_index() 141 141 5 142 142 143 # Check edge case: with allow_empty_first_page=False and list len=1, num_pages should be 1 144 >>> paginator = Paginator([1], 5, 0, False) 145 >>> paginator.count 146 1 147 >>> paginator.num_pages 148 1 149 >>> paginator.page_range 150 [1] 151 152 143 153 ################################ 144 154 # Legacy API (ObjectPaginator) # 145 155 ################################