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.SingleObjectTemplateResponseMixindjango.views.generic.base.TemplateResponseMixindjango.views.generic.dates.BaseDateDetailViewdjango.views.generic.dates.YearMixindjango.views.generic.dates.MonthMixindjango.views.generic.dates.DayMixindjango.views.generic.dates.DateMixindjango.views.generic.detail.BaseDetailViewdjango.views.generic.detail.SingleObjectMixindjango.views.generic.base.View
Context
- Includes the single object associated with the
modelspecified in theDateDetailView.
Notes
- Uses a default
template_name_suffixof_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.