基于类的通用视图 - 扁平化索引 — Django 文档
来自菜鸟教程
Django/docs/3.2.x/ref/class-based-views/flattened-index
基于类的通用视图 - 扁平化索引
该索引为基于类的视图提供了参考文档的替代组织。 对于每个视图,类树中的有效属性和方法都在该视图下表示。 有关由定义行为的类组织的参考文档,请参阅 基于类的视图 。
简单的通用视图
View
- class View
属性(带有可选的访问器):
方法
TemplateView
- class TemplateView
属性(带有可选的访问器):
content_type
extra_context
http_method_names
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
方法
as_view()
dispatch()
get()
get_context_data()
head()
http_method_not_allowed()
render_to_response()
setup()
RedirectView
- class RedirectView
属性(带有可选的访问器):
方法
as_view()
delete()
dispatch()
get()
head()
http_method_not_allowed()
options()
post()
put()
setup()
详细视图
DetailView
- class DetailView
属性(带有可选的访问器):
content_type
- context_object_name [get_context_object_name()]
extra_context
http_method_names
model
pk_url_kwarg
query_pk_and_slug
- queryset [get_queryset()]
- response_class [render_to_response()]
- slug_field [get_slug_field()]
slug_url_kwarg
template_engine
- template_name [get_template_names()]
template_name_field
template_name_suffix
方法
as_view()
dispatch()
get()
get_context_data()
get_object()
head()
http_method_not_allowed()
render_to_response()
setup()
列表视图
ListView
- class ListView
属性(带有可选的访问器):
- allow_empty [get_allow_empty()]
content_type
- context_object_name [get_context_object_name()]
extra_context
http_method_names
model
- 排序 [get_ordering()]
- paginate_by [get_paginate_by()]
- paginate_orphans [get_paginate_orphans()]
paginator_class
- queryset [get_queryset()]
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
template_name_suffix
方法
as_view()
dispatch()
get()
get_context_data()
get_paginator()
head()
http_method_not_allowed()
paginate_queryset()
render_to_response()
setup()
编辑视图
FormView
- class FormView
属性(带有可选的访问器):
content_type
extra_context
- form_class [get_form_class()]
http_method_names
- 初始 [get_initial()]
- 前缀 [get_prefix()]
- response_class [render_to_response()]
- success_url [get_success_url()]
template_engine
- template_name [get_template_names()]
方法
as_view()
dispatch()
form_invalid()
form_valid()
get()
get_context_data()
get_form()
get_form_kwargs()
http_method_not_allowed()
post()
put()
setup()
CreateView
- class CreateView
属性(带有可选的访问器):
content_type
- context_object_name [get_context_object_name()]
extra_context
fields
- form_class [get_form_class()]
http_method_names
- 初始 [get_initial()]
model
pk_url_kwarg
- 前缀 [get_prefix()]
query_pk_and_slug
- queryset [get_queryset()]
- response_class [render_to_response()]
- slug_field [get_slug_field()]
slug_url_kwarg
- success_url [get_success_url()]
template_engine
- template_name [get_template_names()]
template_name_field
template_name_suffix
方法
as_view()
dispatch()
form_invalid()
form_valid()
get()
get_context_data()
get_form()
get_form_kwargs()
get_object()
head()
http_method_not_allowed()
post()
put()
render_to_response()
setup()
UpdateView
- class UpdateView
属性(带有可选的访问器):
content_type
- context_object_name [get_context_object_name()]
extra_context
fields
- form_class [get_form_class()]
http_method_names
- 初始 [get_initial()]
model
pk_url_kwarg
- 前缀 [get_prefix()]
query_pk_and_slug
- queryset [get_queryset()]
- response_class [render_to_response()]
- slug_field [get_slug_field()]
slug_url_kwarg
- success_url [get_success_url()]
template_engine
- template_name [get_template_names()]
template_name_field
template_name_suffix
方法
as_view()
dispatch()
form_invalid()
form_valid()
get()
get_context_data()
get_form()
get_form_kwargs()
get_object()
head()
http_method_not_allowed()
post()
put()
render_to_response()
setup()
DeleteView
- class DeleteView
属性(带有可选的访问器):
content_type
- context_object_name [get_context_object_name()]
extra_context
http_method_names
model
pk_url_kwarg
query_pk_and_slug
- queryset [get_queryset()]
- response_class [render_to_response()]
- slug_field [get_slug_field()]
slug_url_kwarg
- success_url [get_success_url()]
template_engine
- template_name [get_template_names()]
template_name_field
template_name_suffix
方法
as_view()
delete()
dispatch()
get()
get_context_data()
get_object()
head()
http_method_not_allowed()
post()
render_to_response()
setup()
基于日期的视图
ArchiveIndexView
- class ArchiveIndexView
属性(带有可选的访问器):
- allow_empty [get_allow_empty()]
- allow_future [get_allow_future()]
content_type
- context_object_name [get_context_object_name()]
- date_field [get_date_field()]
extra_context
http_method_names
model
- 排序 [get_ordering()]
- paginate_by [get_paginate_by()]
- paginate_orphans [get_paginate_orphans()]
paginator_class
- queryset [get_queryset()]
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
template_name_suffix
方法
as_view()
dispatch()
get()
get_context_data()
get_date_list()
get_dated_items()
get_dated_queryset()
get_paginator()
head()
http_method_not_allowed()
paginate_queryset()
render_to_response()
setup()
YearArchiveView
- class YearArchiveView
属性(带有可选的访问器):
- allow_empty [get_allow_empty()]
- allow_future [get_allow_future()]
content_type
- context_object_name [get_context_object_name()]
- date_field [get_date_field()]
extra_context
http_method_names
- make_object_list [get_make_object_list()]
model
- 排序 [get_ordering()]
- paginate_by [get_paginate_by()]
- paginate_orphans [get_paginate_orphans()]
paginator_class
- queryset [get_queryset()]
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
template_name_suffix
- 年 [get_year()]
- year_format [get_year_format()]
方法
as_view()
dispatch()
get()
get_context_data()
get_date_list()
get_dated_items()
get_dated_queryset()
get_paginator()
head()
http_method_not_allowed()
paginate_queryset()
render_to_response()
setup()
MonthArchiveView
- class MonthArchiveView
属性(带有可选的访问器):
- allow_empty [get_allow_empty()]
- allow_future [get_allow_future()]
content_type
- context_object_name [get_context_object_name()]
- date_field [get_date_field()]
extra_context
http_method_names
model
- 月 [get_month()]
- month_format [get_month_format()]
- 排序 [get_ordering()]
- paginate_by [get_paginate_by()]
- paginate_orphans [get_paginate_orphans()]
paginator_class
- queryset [get_queryset()]
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
template_name_suffix
- 年 [get_year()]
- year_format [get_year_format()]
方法
as_view()
dispatch()
get()
get_context_data()
get_date_list()
get_dated_items()
get_dated_queryset()
get_next_month()
get_paginator()
get_previous_month()
head()
http_method_not_allowed()
paginate_queryset()
render_to_response()
setup()
WeekArchiveView
- class WeekArchiveView
属性(带有可选的访问器):
- allow_empty [get_allow_empty()]
- allow_future [get_allow_future()]
content_type
- context_object_name [get_context_object_name()]
- date_field [get_date_field()]
extra_context
http_method_names
model
- 排序 [get_ordering()]
- paginate_by [get_paginate_by()]
- paginate_orphans [get_paginate_orphans()]
paginator_class
- queryset [get_queryset()]
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
template_name_suffix
- 周 [get_week()]
- week_format [get_week_format()]
- 年 [get_year()]
- year_format [get_year_format()]
方法
as_view()
dispatch()
get()
get_context_data()
get_date_list()
get_dated_items()
get_dated_queryset()
get_paginator()
head()
http_method_not_allowed()
paginate_queryset()
render_to_response()
setup()
DayArchiveView
- class DayArchiveView
属性(带有可选的访问器):
- allow_empty [get_allow_empty()]
- allow_future [get_allow_future()]
content_type
- context_object_name [get_context_object_name()]
- date_field [get_date_field()]
- 天 [get_day()]
- day_format [get_day_format()]
extra_context
http_method_names
model
- 月 [get_month()]
- month_format [get_month_format()]
- 排序 [get_ordering()]
- paginate_by [get_paginate_by()]
- paginate_orphans [get_paginate_orphans()]
paginator_class
- queryset [get_queryset()]
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
template_name_suffix
- 年 [get_year()]
- year_format [get_year_format()]
方法
as_view()
dispatch()
get()
get_context_data()
get_date_list()
get_dated_items()
get_dated_queryset()
get_next_day()
get_next_month()
get_paginator()
get_previous_day()
get_previous_month()
head()
http_method_not_allowed()
paginate_queryset()
render_to_response()
setup()
TodayArchiveView
- class TodayArchiveView
属性(带有可选的访问器):
- allow_empty [get_allow_empty()]
- allow_future [get_allow_future()]
content_type
- context_object_name [get_context_object_name()]
- date_field [get_date_field()]
- 天 [get_day()]
- day_format [get_day_format()]
extra_context
http_method_names
model
- 月 [get_month()]
- month_format [get_month_format()]
- 排序 [get_ordering()]
- paginate_by [get_paginate_by()]
- paginate_orphans [get_paginate_orphans()]
paginator_class
- queryset [get_queryset()]
- response_class [render_to_response()]
template_engine
- template_name [get_template_names()]
template_name_suffix
- 年 [get_year()]
- year_format [get_year_format()]
方法
as_view()
dispatch()
get()
get_context_data()
get_date_list()
get_dated_items()
get_dated_queryset()
get_next_day()
get_next_month()
get_paginator()
get_previous_day()
get_previous_month()
head()
http_method_not_allowed()
paginate_queryset()
render_to_response()
setup()
DateDetailView
- class DateDetailView
属性(带有可选的访问器):
- allow_future [get_allow_future()]
content_type
- context_object_name [get_context_object_name()]
- date_field [get_date_field()]
- 天 [get_day()]
- day_format [get_day_format()]
extra_context
http_method_names
model
- 月 [get_month()]
- month_format [get_month_format()]
pk_url_kwarg
query_pk_and_slug
- queryset [get_queryset()]
- response_class [render_to_response()]
- slug_field [get_slug_field()]
slug_url_kwarg
template_engine
- template_name [get_template_names()]
template_name_field
template_name_suffix
- 年 [get_year()]
- year_format [get_year_format()]
方法
as_view()
dispatch()
get()
get_context_data()
get_next_day()
get_next_month()
get_object()
get_previous_day()
get_previous_month()
head()
http_method_not_allowed()
render_to_response()
setup()