Ticket #3274: date_list_for_archive_month.diff

File date_list_for_archive_month.diff, 1.8 KB (added by paolo <paolo@…>, 8 years ago)

date_list_for_archive_month

  • django/views/generic/date_based.py

     
    103103
    104104    Templates: ``<app_label>/<model_name>_archive_month.html``
    105105    Context:
     106        date_list
     107            List of days in this month with objects
    106108        month:
    107109            (date) this month
    108110        next_month:
     
    133135    if last_day >= now.date() and not allow_future:
    134136        lookup_kwargs['%s__lte' % date_field] = now
    135137    object_list = queryset.filter(**lookup_kwargs)
    136     if not object_list and not allow_empty:
     138    date_list = object_list.dates(date_field, 'day')
     139    if not date_list and not allow_empty:
    137140        raise Http404
    138141
    139142    # Calculate the next month, if applicable.
     
    148151        template_name = "%s/%s_archive_month.html" % (model._meta.app_label, model._meta.object_name.lower())
    149152    t = template_loader.get_template(template_name)
    150153    c = RequestContext(request, {
     154        'date_list': date_list,
    151155        '%s_list' % template_object_name: object_list,
    152156        'month': date,
    153157        'next_month': next_month,
  • docs/generic_views.txt

     
    381381
    382382In addition to ``extra_context``, the template's context will be:
    383383
     384    * ``date_list``: A list of ``datetime.date`` objects representing all
     385      days that have objects available in the given month, according to
     386      ``queryset``, in ascending order.
     387
    384388    * ``month``: A ``datetime.date`` object representing the given month.
    385389
    386390    * ``next_month``: A ``datetime.date`` object representing the first day of
Back to Top