-
代表單個對象的頁麵。如果對象將來有日期值,則視圖默認會拋出 404 錯誤,除非您將
allow_future設置為True。祖先 (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.SingleObjectMixin- View
語境
- 包括與
DateDetailView中指定的model關聯的單個對象。
注意
- 使用
_detail的默認template_name_suffix。
示例 myapp/urls.py:
from django.urls import path from django.views.generic.dates import DateDetailView urlpatterns = [ path('<int:year>/<str:month>/<int:day>/<int:pk>/', DateDetailView.as_view(model=Article, date_field="pub_date"), name="archive_date_detail"), ]示例 myapp/article_detail.html:
<h1>{{ object.title }}</h1>
本文介紹 django.views.generic.dates.DateDetailView 的用法。
聲明
class DateDetailView
注意
上麵列出的所有通用視圖都有匹配的 Base 視圖,不同之處僅在於它們不包括 (用於存檔視圖)或 MultipleObjectTemplateResponseMixin (用於 SingleObjectTemplateResponseMixin ):DateDetailView
-
classBaseArchiveIndexView
-
classBaseYearArchiveView
-
classBaseMonthArchiveView
-
classBaseWeekArchiveView
-
classBaseDayArchiveView
-
classBaseTodayArchiveView
-
classBaseDateDetailView
相關用法
- Python Datetime.replace()用法及代碼示例
- Python DateTime轉integer用法及代碼示例
- Python DateTime astimezone()用法及代碼示例
- Python Django DateTimeField.input_formats用法及代碼示例
- Python DateTime weekday()用法及代碼示例
- Python Django DataSource用法及代碼示例
- Python DataFrame.to_excel()用法及代碼示例
- Python Tableau DatasourceItem用法及代碼示例
- Python DataFrame.read_pickle()用法及代碼示例
- Python Pandas DataFrame.fillna()用法及代碼示例
- Python Django DayArchiveView用法及代碼示例
- Python Decimal shift()用法及代碼示例
- Python Decimal rotate()用法及代碼示例
- Python Decimal max_mag()用法及代碼示例
- Python Decimal as_integer_ratio()用法及代碼示例
- Python Decimal is_subnormal()用法及代碼示例
- Python Decimal canonical()用法及代碼示例
- Python Decimal from_float()用法及代碼示例
- Python Decimal normalize()用法及代碼示例
- Python Decimal radix()用法及代碼示例
- Python Dictionary update()用法及代碼示例
- Python Decimal copy_abs()用法及代碼示例
- Python Decimal is_finite()用法及代碼示例
- Python Decimal conjugate()用法及代碼示例
- Python Django Distance用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.views.generic.dates.DateDetailView。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
