class DateDetailView
[source]
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)
django.views.generic.detail.SingleObjectTemplateResponseMixin
django.views.generic.base.TemplateResponseMixin
django.views.generic.dates.BaseDateDetailView
django.views.generic.dates.YearMixin
django.views.generic.dates.MonthMixin
django.views.generic.dates.DayMixin
django.views.generic.dates.DateMixin
django.views.generic.detail.BaseDetailView
django.views.generic.detail.SingleObjectMixin
django.views.generic.base.View
Context
- Includes the single object associated with the
model
specified in theDateDetailView
.
Notes
- Uses a default
template_name_suffix
of_detail
.
Example myapp/urls.py:
from django.conf.urls import url from django.views.generic.dates import DateDetailView urlpatterns = [ url(r'^(?P<year>[0-9]{4})/(?P<month>[-\w]+)/(?P<day>[0-9]+)/(?P<pk>[0-9]+)/$', DateDetailView.as_view(model=Article, date_field="pub_date"), name="archive_date_detail"), ]
Example myapp/article_detail.html:
<h1>{{ object.title }}</h1>
Note
All of the generic views listed above have matching Base
views that only differ in that they do not include the MultipleObjectTemplateResponseMixin
(for the archive views) or SingleObjectTemplateResponseMixin
(for the DateDetailView
):
-
class BaseArchiveIndexView
[source]
-
class BaseYearArchiveView
[source]
-
class BaseMonthArchiveView
[source]
-
class BaseWeekArchiveView
[source]
-
class BaseDayArchiveView
[source]
-
class BaseTodayArchiveView
[source]
-
class BaseDateDetailView
[source]
Please login to continue.