Ticket #4956: reverse_pagination.patch
File reverse_pagination.patch, 1.3 KB (added by , 17 years ago) |
---|
-
views/generic/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 … … 45 45 if paginate_by: 46 46 paginator = ObjectPaginator(queryset, paginate_by) 47 47 if not page: 48 page = request.GET.get('page', 1) 48 if reverse_pagination: 49 page = request.GET.get('page', paginator.pages) 50 else: 51 page = request.GET.get('page', 1) 49 52 try: 50 53 page = int(page) 51 54 object_list = paginator.get_page(page - 1) … … 54 57 object_list = [] 55 58 else: 56 59 raise Http404 60 if reverse_pagination: 61 object_list = list(reversed(list(object_list))) 57 62 c = RequestContext(request, { 58 63 '%s_list' % template_object_name: object_list, 59 64 'is_paginated': paginator.pages > 1,