Tutorial Writing your first Django app, part 5 Test a view
What we have works well; however, even though future questions don’t appear in the index, users can still reach them if they know or guess the right URL.
766 sections in Django dev Search all versions →
Tutorial Writing your first Django app, part 5 Test a view
What we have works well; however, even though future questions don’t appear in the index, users can still reach them if they know or guess the right URL.
Design philosophies Database API
This is also why the FETCH_PEERS fetch mode exists. It’s an optional performance booster for the common case of selecting related objects for every peer in a QuerySet.
Reference Class-based generic views - flattened index Detail Views
classDetailView Attributes (with optional accessor): 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 Methods as_view() dispatch() get() get_context_data() get_object() head() http_method_not_allowed() render_to_response() setup()
Reference Class-based generic views - flattened index List Views
classListView Attributes (with optional accessor): allow_empty [get_allow_empty()] content_type context_object_name [get_context_object_name()] extra_context http_method_names model ordering [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 Methods as_view() dispatch() get() get_context_data() get_paginator() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()
Reference Class-based generic views - flattened index Editing views
classCreateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [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 Methods as_view() dispatch() form_invalid() form_valid() get() …
Reference Class-based generic views - flattened index Editing views
classUpdateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [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 Methods as_view() dispatch() form_invalid() form_valid() get() …
Reference Class-based generic views - flattened index Editing views
classDeleteView Attributes (with optional accessor): 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 Methods as_view() delete() dispatch() get() get_context_data() get_object() head() http_method_not_allowed() post() render_to_response() setup()
Reference Class-based generic views - flattened index Date-based views
Methods 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()
Reference Class-based generic views - flattened index Date-based views
Methods 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()
Reference Class-based generic views - flattened index Date-based views
Methods 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()
Reference Class-based generic views - flattened index Date-based views
Methods 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()
Reference Class-based generic views - flattened index Date-based views
Methods 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()
Reference Generic date views
classArchiveIndexView[source] : A top-level index page showing the “latest” objects, by date. Objects with a date in the future are not included unless you set allow_future to True.
Reference Generic date views
classYearArchiveView[source] : A yearly archive page showing all available months in a given year. Objects with a date in the future are not displayed unless you set allow_future to True.
Reference Generic date views
classMonthArchiveView[source] : A monthly archive page showing all objects in a given month. Objects with a date in the future are not displayed unless you set allow_future to True.
Reference Generic date views
classTodayArchiveView[source] : A day archive page showing all objects for today. This is exactly the same as django.views.generic.dates.DayArchiveView, except today’s date is used instead of the year/month/day arguments.
Reference Generic display views
classdjango.views.generic.detail.DetailView : While this view is executing, self.object will contain the object that the view is operating upon. classdjango.views.generic.detail.BaseDetailView : A base view for displaying a single object.
Reference Built-in class-based views API
Most generic views require the queryset key, which is a QuerySet instance; see Making queries for more information about QuerySet objects.
Reference Editing mixins
classdjango.views.generic.edit.ModelFormMixin : A form mixin that provides facilities for working with a ModelForm, rather than a standalone form.
Reference Multiple object mixins
`context_object_name` : Designates the name of the variable to use in the context. `get_queryset()` : Get the list of items for this view. This must be an iterable and may be a queryset (in which queryset-specific behavior will be enabled).