Date-Based Generic Views

Date-based generic views, provided in django.views.generic.dates, are views for displaying drilldown pages for date-based data.

ArchiveIndexView

A top-level index page showing the latest objects, by date. Objects with a date in the future are not included unless you set allow_future to True.

Context

In addition to the context provided by django.views.generic.list.MultipleObjectMixin (via django.views.generic.dates.BaseDateListView), the template's context will be:

  • date_list: A DateQuerySet object containing all years that have objects available according to queryset, represented as datetime.datetime objects, in descending order

Notes

  • Uses a default context_object_name of latest.
  • Uses a default template_name_suffix of _archive ...

Get Mastering Django: Core now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.