Ticket #697: django.patch

File django.patch, 1.6 KB (added by jhf@…, 19 years ago)

Patch for django/views/generic/date_based.py

  • django/views/generic/date_based.py

     
    5151
    5252def archive_year(request, year, app_label, module_name, date_field,
    5353                 template_name=None, template_loader=template_loader,
    54                  extra_lookup_kwargs={}, extra_context={}):
     54                 extra_lookup_kwargs={}, extra_context={}, make_object_list=False):
    5555    """
    5656    Generic yearly archive view.
    5757
     
    6161            List of months in this year with objects
    6262        year
    6363            This year
     64        object_list
     65            list of objects published in the given year
     66            Only when keyword argumement make_object_list=True
    6467    """
    6568    mod = get_module(app_label, module_name)
    6669    now = datetime.datetime.now()
     
    7275    date_list = getattr(mod, "get_%s_list" % date_field)('month', **lookup_kwargs)
    7376    if not date_list:
    7477        raise Http404
     78    if make_object_list:
     79        lookup_kwargs.update({'order_by': ('-' + date_field,)})
     80        object_list = mod.get_list(**lookup_kwargs)
     81    else:
     82        object_list = []
    7583    if not template_name:
    7684        template_name = "%s/%s_archive_year" % (app_label, module_name)
    7785    t = template_loader.get_template(template_name)
    7886    c = Context(request, {
    7987        'date_list': date_list,
    8088        'year': year,
     89        'object_list':object_list,
    8190    })
    8291    for key, value in extra_context.items():
    8392        if callable(value):
Back to Top