Ticket #2450: sort.patch

File sort.patch, 1005 bytes (added by noods, 18 years ago)
  • django/views/generic/date_based.py

     
    77def archive_index(request, queryset, date_field, num_latest=15,
    88        template_name=None, template_loader=loader,
    99        extra_context=None, allow_empty=False, context_processors=None,
    10         mimetype=None, allow_future=False):
     10        mimetype=None, allow_future=False, sort_ascending=False):
    1111    """
    1212    Generic top-level archive of date-based objects.
    1313
     
    2727        raise Http404, "No %s available" % model._meta.verbose_name
    2828
    2929    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]
    3134    else:
    3235        latest = None
    3336
Back to Top