Ticket #3274: date_list_for_archive_month.diff
File date_list_for_archive_month.diff, 1.8 KB (added by , 18 years ago) |
---|
-
django/views/generic/date_based.py
103 103 104 104 Templates: ``<app_label>/<model_name>_archive_month.html`` 105 105 Context: 106 date_list 107 List of days in this month with objects 106 108 month: 107 109 (date) this month 108 110 next_month: … … 133 135 if last_day >= now.date() and not allow_future: 134 136 lookup_kwargs['%s__lte' % date_field] = now 135 137 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: 137 140 raise Http404 138 141 139 142 # Calculate the next month, if applicable. … … 148 151 template_name = "%s/%s_archive_month.html" % (model._meta.app_label, model._meta.object_name.lower()) 149 152 t = template_loader.get_template(template_name) 150 153 c = RequestContext(request, { 154 'date_list': date_list, 151 155 '%s_list' % template_object_name: object_list, 152 156 'month': date, 153 157 'next_month': next_month, -
docs/generic_views.txt
381 381 382 382 In addition to ``extra_context``, the template's context will be: 383 383 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 384 388 * ``month``: A ``datetime.date`` object representing the given month. 385 389 386 390 * ``next_month``: A ``datetime.date`` object representing the first day of