Class-based generic views - flattened index¶
This index provides an alternate organization of the reference documentation for class-based views. For each view, the effective attributes and methods from the class tree are represented under that view. For the reference documentation organized by the class which defines the behavior, see Class-based views.
参见
Classy Class-Based Views provides a nice interface to navigate the class hierarchy of the built-in class-based views.
Simple generic views¶
TemplateView¶
-
class
TemplateView¶
Attributes (with optional accessor):
content_typeextra_contexthttp_method_namesresponse_class[render_to_response()]template_enginetemplate_name[get_template_names()]
方法
RedirectView¶
-
class
RedirectView¶
Attributes (with optional accessor):
方法
as_view()delete()dispatch()get()head()http_method_not_allowed()options()post()put()setup()
详情视图¶
DetailView¶
-
class
DetailView¶
Attributes (with optional accessor):
content_typecontext_object_name[get_context_object_name()]extra_contexthttp_method_namesmodelpk_url_kwargqueryset[get_queryset()]response_class[render_to_response()]slug_field[get_slug_field()]slug_url_kwargtemplate_enginetemplate_name[get_template_names()]template_name_fieldtemplate_name_suffix
方法
列表视图¶
ListView¶
-
class
ListView¶
Attributes (with optional accessor):
allow_empty[get_allow_empty()]content_typecontext_object_name[get_context_object_name()]extra_contexthttp_method_namesmodelordering[get_ordering()]paginate_by[get_paginate_by()]paginate_orphans[get_paginate_orphans()]paginator_classqueryset[get_queryset()]response_class[render_to_response()]template_enginetemplate_name[get_template_names()]template_name_suffix
方法
编辑视图¶
FormView¶
-
class
FormView¶
Attributes (with optional accessor):
content_typeextra_contextform_class[get_form_class()]http_method_namesinitial[get_initial()]prefix[get_prefix()]response_class[render_to_response()]success_url[get_success_url()]template_enginetemplate_name[get_template_names()]
方法
CreateView¶
-
class
CreateView¶
Attributes (with optional accessor):
content_typecontext_object_name[get_context_object_name()]extra_contextfieldsform_class[get_form_class()]http_method_namesinitial[get_initial()]modelpk_url_kwargprefix[get_prefix()]queryset[get_queryset()]response_class[render_to_response()]slug_field[get_slug_field()]slug_url_kwargsuccess_url[get_success_url()]template_enginetemplate_name[get_template_names()]template_name_fieldtemplate_name_suffix
方法
UpdateView¶
-
class
UpdateView¶
Attributes (with optional accessor):
content_typecontext_object_name[get_context_object_name()]extra_contextfieldsform_class[get_form_class()]http_method_namesinitial[get_initial()]modelpk_url_kwargprefix[get_prefix()]queryset[get_queryset()]response_class[render_to_response()]slug_field[get_slug_field()]slug_url_kwargsuccess_url[get_success_url()]template_enginetemplate_name[get_template_names()]template_name_fieldtemplate_name_suffix
方法
DeleteView¶
-
class
DeleteView¶
Attributes (with optional accessor):
content_typecontext_object_name[get_context_object_name()]extra_contexthttp_method_namesmodelpk_url_kwargqueryset[get_queryset()]response_class[render_to_response()]slug_field[get_slug_field()]slug_url_kwargsuccess_url[get_success_url()]template_enginetemplate_name[get_template_names()]template_name_fieldtemplate_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¶
Attributes (with optional accessor):
allow_empty[get_allow_empty()]allow_future[get_allow_future()]content_typecontext_object_name[get_context_object_name()]date_field[get_date_field()]extra_contexthttp_method_namesmodelordering[get_ordering()]paginate_by[get_paginate_by()]paginate_orphans[get_paginate_orphans()]paginator_classqueryset[get_queryset()]response_class[render_to_response()]template_enginetemplate_name[get_template_names()]template_name_suffix
方法
YearArchiveView¶
-
class
YearArchiveView¶
Attributes (with optional accessor):
allow_empty[get_allow_empty()]allow_future[get_allow_future()]content_typecontext_object_name[get_context_object_name()]date_field[get_date_field()]extra_contexthttp_method_namesmake_object_list[get_make_object_list()]modelordering[get_ordering()]paginate_by[get_paginate_by()]paginate_orphans[get_paginate_orphans()]paginator_classqueryset[get_queryset()]response_class[render_to_response()]template_enginetemplate_name[get_template_names()]template_name_suffixyear[get_year()]year_format[get_year_format()]
方法
MonthArchiveView¶
-
class
MonthArchiveView¶
Attributes (with optional accessor):
allow_empty[get_allow_empty()]allow_future[get_allow_future()]content_typecontext_object_name[get_context_object_name()]date_field[get_date_field()]extra_contexthttp_method_namesmodelmonth[get_month()]month_format[get_month_format()]ordering[get_ordering()]paginate_by[get_paginate_by()]paginate_orphans[get_paginate_orphans()]paginator_classqueryset[get_queryset()]response_class[render_to_response()]template_enginetemplate_name[get_template_names()]template_name_suffixyear[get_year()]year_format[get_year_format()]
方法
WeekArchiveView¶
-
class
WeekArchiveView¶
Attributes (with optional accessor):
allow_empty[get_allow_empty()]allow_future[get_allow_future()]content_typecontext_object_name[get_context_object_name()]date_field[get_date_field()]extra_contexthttp_method_namesmodelordering[get_ordering()]paginate_by[get_paginate_by()]paginate_orphans[get_paginate_orphans()]paginator_classqueryset[get_queryset()]response_class[render_to_response()]template_enginetemplate_name[get_template_names()]template_name_suffixweek[get_week()]week_format[get_week_format()]year[get_year()]year_format[get_year_format()]
方法
DayArchiveView¶
-
class
DayArchiveView¶
Attributes (with optional accessor):
allow_empty[get_allow_empty()]allow_future[get_allow_future()]content_typecontext_object_name[get_context_object_name()]date_field[get_date_field()]day[get_day()]day_format[get_day_format()]extra_contexthttp_method_namesmodelmonth[get_month()]month_format[get_month_format()]ordering[get_ordering()]paginate_by[get_paginate_by()]paginate_orphans[get_paginate_orphans()]paginator_classqueryset[get_queryset()]response_class[render_to_response()]template_enginetemplate_name[get_template_names()]template_name_suffixyear[get_year()]year_format[get_year_format()]
方法
TodayArchiveView¶
-
class
TodayArchiveView¶
Attributes (with optional accessor):
allow_empty[get_allow_empty()]allow_future[get_allow_future()]content_typecontext_object_name[get_context_object_name()]date_field[get_date_field()]day[get_day()]day_format[get_day_format()]extra_contexthttp_method_namesmodelmonth[get_month()]month_format[get_month_format()]ordering[get_ordering()]paginate_by[get_paginate_by()]paginate_orphans[get_paginate_orphans()]paginator_classqueryset[get_queryset()]response_class[render_to_response()]template_enginetemplate_name[get_template_names()]template_name_suffixyear[get_year()]year_format[get_year_format()]
方法
DateDetailView¶
-
class
DateDetailView¶
Attributes (with optional accessor):
allow_future[get_allow_future()]content_typecontext_object_name[get_context_object_name()]date_field[get_date_field()]day[get_day()]day_format[get_day_format()]extra_contexthttp_method_namesmodelmonth[get_month()]month_format[get_month_format()]pk_url_kwargqueryset[get_queryset()]response_class[render_to_response()]slug_field[get_slug_field()]slug_url_kwargtemplate_enginetemplate_name[get_template_names()]template_name_fieldtemplate_name_suffixyear[get_year()]year_format[get_year_format()]
方法