2012-06-11 10:34:00 +02:00
|
|
|
==================
|
|
|
|
Generic date views
|
|
|
|
==================
|
|
|
|
|
|
|
|
Date-based generic views (in the module :mod:`django.views.generic.dates`)
|
|
|
|
are views for displaying drilldown pages for date-based data.
|
|
|
|
|
2012-08-11 08:07:15 +02:00
|
|
|
ArchiveIndexView
|
|
|
|
----------------
|
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
.. class:: django.views.generic.dates.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``.
|
|
|
|
|
|
|
|
**Ancestors (MRO)**
|
|
|
|
|
|
|
|
* :class:`django.views.generic.dates.ArchiveIndexView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseArchiveIndexView`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectMixin`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.base.View`
|
2012-08-11 08:07:15 +02:00
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
**Notes**
|
|
|
|
|
|
|
|
* Uses a default ``context_object_name`` of ``latest``.
|
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive``.
|
|
|
|
|
2012-08-11 08:07:15 +02:00
|
|
|
YearArchiveView
|
|
|
|
---------------
|
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
.. class:: django.views.generic.dates.YearArchiveView
|
|
|
|
|
|
|
|
A yearly archive page showing all available months in a given year. Objects
|
|
|
|
with a date in the *future* are not displayed unless you set
|
|
|
|
``allow_future`` to ``True``.
|
|
|
|
|
|
|
|
**Ancestors (MRO)**
|
|
|
|
|
|
|
|
* :class:`django.views.generic.dates.YearArchiveView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseYearArchiveView`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectMixin`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.base.View`
|
|
|
|
|
|
|
|
.. attribute:: make_object_list
|
|
|
|
|
|
|
|
A boolean specifying whether to retrieve the full list of objects for
|
|
|
|
this year and pass those to the template. If ``True``, the list of
|
|
|
|
objects will be made available to the context. By default, this is
|
|
|
|
``False``.
|
|
|
|
|
|
|
|
.. method:: get_make_object_list()
|
|
|
|
|
|
|
|
Determine if an object list will be returned as part of the context. If
|
|
|
|
``False``, the ``None`` queryset will be used as the object list.
|
|
|
|
|
|
|
|
**Context**
|
|
|
|
|
|
|
|
In addition to the context provided by
|
|
|
|
:class:`django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
|
|
|
|
|
|
|
* ``date_list``: A
|
|
|
|
:meth:`DateQuerySet<django.db.models.query.QuerySet.dates>` object object
|
|
|
|
containing all months that have objects available according to
|
|
|
|
``queryset``, represented as
|
|
|
|
:class:`datetime.datetime<python:datetime.datetime>` objects, in
|
|
|
|
ascending order.
|
|
|
|
|
|
|
|
* ``year``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the given year.
|
|
|
|
|
|
|
|
* ``next_year``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the next year. If the next year is in the
|
|
|
|
future, this will be ``None``.
|
|
|
|
|
|
|
|
* ``previous_year``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the previous year. Unlike ``next_year``,
|
|
|
|
this will never be ``None``.
|
|
|
|
|
|
|
|
**Notes**
|
|
|
|
|
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_year``.
|
|
|
|
|
2012-08-11 08:07:15 +02:00
|
|
|
MonthArchiveView
|
|
|
|
----------------
|
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
.. class:: django.views.generic.dates.MonthArchiveView
|
|
|
|
|
|
|
|
A monthly archive page showing all objects in a given month. Objects with a
|
|
|
|
date in the *future* are not displayed unless you set ``allow_future`` to
|
|
|
|
``True``.
|
|
|
|
|
|
|
|
**Ancestors (MRO)**
|
|
|
|
|
|
|
|
* :class:`django.views.generic.dates.MonthArchiveView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseMonthArchiveView`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectMixin`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.base.View`
|
|
|
|
|
|
|
|
**Context**
|
|
|
|
|
|
|
|
In addition to the context provided by
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`~django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
|
|
|
|
|
|
|
* ``date_list``: A
|
|
|
|
:meth:`DateQuerySet<django.db.models.query.QuerySet.dates>` object
|
|
|
|
containing all days that have objects available in the given month,
|
|
|
|
according to ``queryset``, represented as
|
|
|
|
:class:`datetime.datetime<python:datetime.datetime>` objects, in
|
|
|
|
ascending order.
|
|
|
|
|
|
|
|
* ``month``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the given month.
|
|
|
|
|
|
|
|
* ``next_month``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the next month. If the next month is in the
|
|
|
|
future, this will be ``None``.
|
|
|
|
|
|
|
|
* ``previous_month``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the previous month. Unlike ``next_month``,
|
|
|
|
this will never be ``None``.
|
|
|
|
|
|
|
|
**Notes**
|
|
|
|
|
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_month``.
|
|
|
|
|
2012-08-11 08:07:15 +02:00
|
|
|
WeekArchiveView
|
|
|
|
---------------
|
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
.. class:: django.views.generic.dates.WeekArchiveView
|
|
|
|
|
|
|
|
A weekly archive page showing all objects in a given week. Objects with a
|
|
|
|
date in the *future* are not displayed unless you set ``allow_future`` to
|
|
|
|
``True``.
|
|
|
|
|
|
|
|
**Ancestors (MRO)**
|
|
|
|
|
|
|
|
* :class:`django.views.generic.dates.WeekArchiveView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseWeekArchiveView`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.WeekMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectMixin`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.base.View`
|
|
|
|
|
|
|
|
**Context**
|
|
|
|
|
|
|
|
In addition to the context provided by
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`~django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
|
|
|
|
|
|
|
* ``week``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the given week.
|
|
|
|
|
|
|
|
* ``next_week``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the next week. If the next week is in the
|
|
|
|
future, this will be ``None``.
|
|
|
|
|
|
|
|
* ``previous_week``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the previous week. Unlike ``next_week``,
|
|
|
|
this will never be ``None``.
|
|
|
|
|
|
|
|
**Notes**
|
|
|
|
|
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_week``.
|
|
|
|
|
2012-08-11 08:07:15 +02:00
|
|
|
DayArchiveView
|
|
|
|
--------------
|
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
.. class:: django.views.generic.dates.DayArchiveView
|
|
|
|
|
|
|
|
A day archive page showing all objects in a given day. Days in the future
|
|
|
|
throw a 404 error, regardless of whether any objects exist for future days,
|
|
|
|
unless you set ``allow_future`` to ``True``.
|
|
|
|
|
|
|
|
**Ancestors (MRO)**
|
|
|
|
|
|
|
|
* :class:`django.views.generic.dates.DayArchiveView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDayArchiveView`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.DayMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectMixin`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.base.View`
|
|
|
|
|
|
|
|
**Context**
|
|
|
|
|
|
|
|
In addition to the context provided by
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`~django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
|
|
|
|
|
|
|
* ``day``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the given day.
|
|
|
|
|
|
|
|
* ``next_day``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the next day. If the next day is in the future, this will be
|
|
|
|
``None``.
|
|
|
|
|
|
|
|
* ``previous_day``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the previous day. Unlike ``next_day``, this will never be
|
|
|
|
``None``.
|
|
|
|
|
|
|
|
* ``next_month``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the next month. If the next month is in the
|
|
|
|
future, this will be ``None``.
|
|
|
|
|
|
|
|
* ``previous_month``: A :class:`datetime.date<python:datetime.date>` object
|
|
|
|
representing the first day of the previous month. Unlike ``next_month``,
|
|
|
|
this will never be ``None``.
|
|
|
|
|
|
|
|
**Notes**
|
|
|
|
|
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_day``.
|
|
|
|
|
2012-08-11 08:07:15 +02:00
|
|
|
TodayArchiveView
|
|
|
|
----------------
|
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
.. class:: django.views.generic.dates.TodayArchiveView
|
|
|
|
|
|
|
|
A day archive page showing all objects for *today*. This is exactly the
|
|
|
|
same as :class:`django.views.generic.dates.DayArchiveView`, except today's
|
|
|
|
date is used instead of the ``year``/``month``/``day`` arguments.
|
|
|
|
|
|
|
|
**Ancestors (MRO)**
|
|
|
|
|
|
|
|
* :class:`django.views.generic.dates.TodayArchiveView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseTodayArchiveView`
|
|
|
|
* :class:`django.views.generic.dates.BaseDayArchiveView`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.DayMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectMixin`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.base.View`
|
|
|
|
|
2012-08-11 08:07:15 +02:00
|
|
|
|
|
|
|
DateDetailView
|
|
|
|
--------------
|
|
|
|
|
2012-06-11 10:34:00 +02:00
|
|
|
.. class:: django.views.generic.dates.DateDetailView
|
|
|
|
|
|
|
|
A page representing an individual object. If the object has a date value in
|
|
|
|
the future, the view will throw a 404 error by default, unless you set
|
|
|
|
``allow_future`` to ``True``.
|
|
|
|
|
|
|
|
**Ancestors (MRO)**
|
|
|
|
|
|
|
|
* :class:`django.views.generic.dates.DateDetailView`
|
|
|
|
* :class:`django.views.generic.detail.SingleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateDetailView`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.DayMixin`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.detail.BaseDetailView`
|
|
|
|
* :class:`django.views.generic.detail.SingleObjectMixin`
|
|
|
|
* :class:`django.views.generic.base.View`
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
All of the generic views listed above have matching Base* views that only
|
|
|
|
differ in that the they do not include the
|
|
|
|
:class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.
|