Ticket #4956: reverse_paginator.patch
File reverse_paginator.patch, 1.5 KB (added by , 17 years ago) |
---|
-
list_detail.py
7 7 def object_list(request, queryset, paginate_by=None, page=None, 8 8 allow_empty=False, template_name=None, template_loader=loader, 9 9 extra_context=None, context_processors=None, template_object_name='object', 10 mimetype=None ):10 mimetype=None, reverse_pagination=False): 11 11 """ 12 12 Generic list of objects. 13 13 … … 43 43 if extra_context is None: extra_context = {} 44 44 queryset = queryset._clone() 45 45 if paginate_by: 46 paginator = ObjectPaginator(queryset, paginate_by) 46 if reverse_pagination: 47 paginator = ObjectPaginator(queryset, paginate_by, paginate_by - 1) 48 else: 49 paginator = ObjectPaginator(queryset, paginate_by) 47 50 if not page: 48 page = request.GET.get('page', 1) 51 if reverse_pagination: 52 page = request.GET.get('page', paginator.pages) 53 else: 54 page = request.GET.get('page', 1) 49 55 try: 50 56 page = int(page) 51 57 object_list = paginator.get_page(page - 1) … … 54 60 object_list = [] 55 61 else: 56 62 raise Http404 63 if reverse_pagination: 64 object_list = list(reversed(list(object_list))) 57 65 c = RequestContext(request, { 58 66 '%s_list' % template_object_name: object_list, 59 67 'is_paginated': paginator.pages > 1,