Ticket #2450: sort.patch
File sort.patch, 1005 bytes (added by , 18 years ago) |
---|
-
django/views/generic/date_based.py
7 7 def archive_index(request, queryset, date_field, num_latest=15, 8 8 template_name=None, template_loader=loader, 9 9 extra_context=None, allow_empty=False, context_processors=None, 10 mimetype=None, allow_future=False ):10 mimetype=None, allow_future=False, sort_ascending=False): 11 11 """ 12 12 Generic top-level archive of date-based objects. 13 13 … … 27 27 raise Http404, "No %s available" % model._meta.verbose_name 28 28 29 29 if date_list and num_latest: 30 latest = queryset.order_by('-'+date_field)[:num_latest] 30 if sort_ascending: 31 latest = queryset.order_by(date_field)[:num_latest] 32 else: 33 latest = queryset.order_by('-'+date_field)[:num_latest] 31 34 else: 32 35 latest = None 33 36