Ticket #3391: generic_object_list.2.patch
File generic_object_list.2.patch, 2.4 KB (added by , 18 years ago) |
---|
-
django/core/paginator.py
19 19 self.query_set = query_set 20 20 self.num_per_page = num_per_page 21 21 self.orphans = orphans 22 self._hits = self._pages = None22 self._hits = self._pages = self._page_numbers = None 23 23 24 24 def validate_page_number(self, page_number): 25 25 try: … … 82 82 if hits < 1: 83 83 hits = 0 84 84 self._pages = hits // self.num_per_page + 1 85 self._page_numbers = range(1, self._pages+1) 85 86 return self._pages 87 88 def _get_page_numbers(self): 89 if self._page_numbers is None: 90 self._get_pages() 91 return self._page_numbers 86 92 87 93 hits = property(_get_hits) 88 94 pages = property(_get_pages) 95 page_numbers = property(_get_page_numbers) -
django/views/generic/list_detail.py
48 48 object_list = [] 49 49 else: 50 50 raise Http404 51 51 52 c = RequestContext(request, { 52 53 '%s_list' % template_object_name: object_list, 53 54 'is_paginated': paginator.pages > 1, … … 58 59 'next': page + 1, 59 60 'previous': page - 1, 60 61 'pages': paginator.pages, 62 'page_numbers': paginator.page_numbers, 63 'page_first_item_num': paginator.first_on_page(page - 1), 64 'page_last_item_num': paginator.last_on_page(page - 1), 61 65 'hits' : paginator.hits, 62 66 }, context_processors) 63 67 else: -
docs/generic_views.txt
754 754 755 755 * ``pages``: The total number of pages, as an integer. 756 756 757 * ``page_numbers``: The list of page numbers (integers). 758 759 * ``page_first_item_num``: The number of the first item on the page. 760 761 * ``page_last_item_num``: The number of the last item on the page. 762 757 763 * ``hits``: The total number of objects across *all* pages, not just this 758 764 page. 759 765