doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
month Optional The value for the month, as a string. By default, set to None, which means the month will be determined using other means.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.MonthMixin.month
month_format The strftime() format to use when parsing the month. By default, this is '%b'.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.MonthMixin.month_format
class TodayArchiveView 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. Ancestors (MRO) django.views.generic.list.MultipleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.dates.BaseTodayArchiveView django.views.generic.dates.BaseDayArchiveView django.views.generic.dates.YearMixin django.views.generic.dates.MonthMixin django.views.generic.dates.DayMixin django.views.generic.dates.BaseDateListView django.views.generic.list.MultipleObjectMixin django.views.generic.dates.DateMixin django.views.generic.base.View Notes Uses a default template_name_suffix of _archive_today. Example myapp/views.py: from django.views.generic.dates import TodayArchiveView from myapp.models import Article class ArticleTodayArchiveView(TodayArchiveView): queryset = Article.objects.all() date_field = "pub_date" allow_future = True Example myapp/urls.py: from django.urls import path from myapp.views import ArticleTodayArchiveView urlpatterns = [ path('today/', ArticleTodayArchiveView.as_view(), name="archive_today"), ] Where is the example template for TodayArchiveView? This view uses by default the same template as the DayArchiveView, which is in the previous example. If you need a different template, set the template_name attribute to be the name of the new template.
django.ref.class-based-views.generic-date-based#django.views.generic.dates.TodayArchiveView
class WeekArchiveView A weekly archive page showing all objects in a given week. Objects with a date in the future are not displayed unless you set allow_future to True. Ancestors (MRO) django.views.generic.list.MultipleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.dates.BaseWeekArchiveView django.views.generic.dates.YearMixin django.views.generic.dates.WeekMixin django.views.generic.dates.BaseDateListView django.views.generic.list.MultipleObjectMixin django.views.generic.dates.DateMixin django.views.generic.base.View Context In addition to the context provided by MultipleObjectMixin (via BaseDateListView), the template’s context will be: week: A date object representing the first day of the given week. next_week: A date object representing the first day of the next week, according to allow_empty and allow_future. previous_week: A date object representing the first day of the previous week, according to allow_empty and allow_future. Notes Uses a default template_name_suffix of _archive_week. The week_format attribute is a strptime() format string used to parse the week number. The following values are supported: '%U': Based on the United States week system where the week begins on Sunday. This is the default value. '%W': Similar to '%U', except it assumes that the week begins on Monday. This is not the same as the ISO 8601 week number. '%V': ISO 8601 week number where the week begins on Monday. New in Django 3.2: Support for the '%V' week format was added. Example myapp/views.py: from django.views.generic.dates import WeekArchiveView from myapp.models import Article class ArticleWeekArchiveView(WeekArchiveView): queryset = Article.objects.all() date_field = "pub_date" week_format = "%W" allow_future = True Example myapp/urls.py: from django.urls import path from myapp.views import ArticleWeekArchiveView urlpatterns = [ # Example: /2012/week/23/ path('<int:year>/week/<int:week>/', ArticleWeekArchiveView.as_view(), name="archive_week"), ] Example myapp/article_archive_week.html: <h1>Week {{ week|date:'W' }}</h1> <ul> {% for article in object_list %} <li>{{ article.pub_date|date:"F j, Y" }}: {{ article.title }}</li> {% endfor %} </ul> <p> {% if previous_week %} Previous Week: {{ previous_week|date:"W" }} of year {{ previous_week|date:"Y" }} {% endif %} {% if previous_week and next_week %}--{% endif %} {% if next_week %} Next week: {{ next_week|date:"W" }} of year {{ next_week|date:"Y" }} {% endif %} </p> In this example, you are outputting the week number. Keep in mind that week numbers computed by the date template filter with the 'W' format character are not always the same as those computed by strftime() and strptime() with the '%W' format string. For year 2015, for example, week numbers output by date are higher by one compared to those output by strftime(). There isn’t an equivalent for the '%U' strftime() format string in date. Therefore, you should avoid using date to generate URLs for WeekArchiveView.
django.ref.class-based-views.generic-date-based#django.views.generic.dates.WeekArchiveView
class WeekMixin A mixin that can be used to retrieve and provide parsing information for a week component of a date. Methods and Attributes week_format The strftime() format to use when parsing the week. By default, this is '%U', which means the week starts on Sunday. Set it to '%W' or '%V' (ISO 8601 week) if your week starts on Monday. New in Django 3.2: Support for the '%V' week format was added. week Optional The value for the week, as a string. By default, set to None, which means the week will be determined using other means. get_week_format() Returns the strftime() format to use when parsing the week. Returns week_format by default. get_week() Returns the week for which this view will display data, as a string. Tries the following sources, in order: The value of the WeekMixin.week attribute. The value of the week argument captured in the URL pattern The value of the week GET query argument. Raises a 404 if no valid week specification can be found. get_next_week(date) Returns a date object containing the first day of the week after the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future. get_prev_week(date) Returns a date object containing the first day of the week before the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.WeekMixin
get_next_week(date) Returns a date object containing the first day of the week after the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.WeekMixin.get_next_week
get_prev_week(date) Returns a date object containing the first day of the week before the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.WeekMixin.get_prev_week
get_week() Returns the week for which this view will display data, as a string. Tries the following sources, in order: The value of the WeekMixin.week attribute. The value of the week argument captured in the URL pattern The value of the week GET query argument. Raises a 404 if no valid week specification can be found.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.WeekMixin.get_week
get_week_format() Returns the strftime() format to use when parsing the week. Returns week_format by default.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.WeekMixin.get_week_format
week Optional The value for the week, as a string. By default, set to None, which means the week will be determined using other means.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.WeekMixin.week
week_format The strftime() format to use when parsing the week. By default, this is '%U', which means the week starts on Sunday. Set it to '%W' or '%V' (ISO 8601 week) if your week starts on Monday. New in Django 3.2: Support for the '%V' week format was added.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.WeekMixin.week_format
class YearArchiveView 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. Ancestors (MRO) django.views.generic.list.MultipleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.dates.BaseYearArchiveView django.views.generic.dates.YearMixin django.views.generic.dates.BaseDateListView django.views.generic.list.MultipleObjectMixin django.views.generic.dates.DateMixin django.views.generic.base.View make_object_list A boolean specifying whether to retrieve the full list of objects for this year and pass those to the template. If True, the list of objects will be made available to the context. If False, the None queryset will be used as the object list. By default, this is False. get_make_object_list() Determine if an object list will be returned as part of the context. Returns make_object_list by default. Context In addition to the context provided by django.views.generic.list.MultipleObjectMixin (via django.views.generic.dates.BaseDateListView), the template’s context will be: date_list: A QuerySet object containing all months that have objects available according to queryset, represented as datetime.datetime objects, in ascending order. year: A date object representing the given year. next_year: A date object representing the first day of the next year, according to allow_empty and allow_future. previous_year: A date object representing the first day of the previous year, according to allow_empty and allow_future. Notes Uses a default template_name_suffix of _archive_year. Example myapp/views.py: from django.views.generic.dates import YearArchiveView from myapp.models import Article class ArticleYearArchiveView(YearArchiveView): queryset = Article.objects.all() date_field = "pub_date" make_object_list = True allow_future = True Example myapp/urls.py: from django.urls import path from myapp.views import ArticleYearArchiveView urlpatterns = [ path('<int:year>/', ArticleYearArchiveView.as_view(), name="article_year_archive"), ] Example myapp/article_archive_year.html: <ul> {% for date in date_list %} <li>{{ date|date }}</li> {% endfor %} </ul> <div> <h1>All Articles for {{ year|date:"Y" }}</h1> {% for obj in object_list %} <p> {{ obj.title }} - {{ obj.pub_date|date:"F j, Y" }} </p> {% endfor %} </div>
django.ref.class-based-views.generic-date-based#django.views.generic.dates.YearArchiveView
get_make_object_list() Determine if an object list will be returned as part of the context. Returns make_object_list by default.
django.ref.class-based-views.generic-date-based#django.views.generic.dates.YearArchiveView.get_make_object_list
make_object_list A boolean specifying whether to retrieve the full list of objects for this year and pass those to the template. If True, the list of objects will be made available to the context. If False, the None queryset will be used as the object list. By default, this is False.
django.ref.class-based-views.generic-date-based#django.views.generic.dates.YearArchiveView.make_object_list
class YearMixin A mixin that can be used to retrieve and provide parsing information for a year component of a date. Methods and Attributes year_format The strftime() format to use when parsing the year. By default, this is '%Y'. year Optional The value for the year, as a string. By default, set to None, which means the year will be determined using other means. get_year_format() Returns the strftime() format to use when parsing the year. Returns year_format by default. get_year() Returns the year for which this view will display data, as a string. Tries the following sources, in order: The value of the YearMixin.year attribute. The value of the year argument captured in the URL pattern. The value of the year GET query argument. Raises a 404 if no valid year specification can be found. get_next_year(date) Returns a date object containing the first day of the year after the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future. get_previous_year(date) Returns a date object containing the first day of the year before the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.YearMixin
get_next_year(date) Returns a date object containing the first day of the year after the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.YearMixin.get_next_year
get_previous_year(date) Returns a date object containing the first day of the year before the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.YearMixin.get_previous_year
get_year() Returns the year for which this view will display data, as a string. Tries the following sources, in order: The value of the YearMixin.year attribute. The value of the year argument captured in the URL pattern. The value of the year GET query argument. Raises a 404 if no valid year specification can be found.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.YearMixin.get_year
get_year_format() Returns the strftime() format to use when parsing the year. Returns year_format by default.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.YearMixin.get_year_format
year Optional The value for the year, as a string. By default, set to None, which means the year will be determined using other means.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.YearMixin.year
year_format The strftime() format to use when parsing the year. By default, this is '%Y'.
django.ref.class-based-views.mixins-date-based#django.views.generic.dates.YearMixin.year_format
class django.views.generic.detail.BaseDetailView A base view for displaying a single object. It is not intended to be used directly, but rather as a parent class of the django.views.generic.detail.DetailView or other views representing details of a single object. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.detail.SingleObjectMixin django.views.generic.base.View Methods get(request, *args, **kwargs) Adds object to the context.
django.ref.class-based-views.generic-display#django.views.generic.detail.BaseDetailView
get(request, *args, **kwargs) Adds object to the context.
django.ref.class-based-views.generic-display#django.views.generic.detail.BaseDetailView.get
class django.views.generic.detail.DetailView While this view is executing, self.object will contain the object that the view is operating upon. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.detail.BaseDetailView django.views.generic.detail.SingleObjectMixin django.views.generic.base.View Method Flowchart setup() dispatch() http_method_not_allowed() get_template_names() get_slug_field() get_queryset() get_object() get_context_object_name() get_context_data() get() render_to_response() Example myapp/views.py: from django.utils import timezone from django.views.generic.detail import DetailView from articles.models import Article class ArticleDetailView(DetailView): model = Article def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['now'] = timezone.now() return context Example myapp/urls.py: from django.urls import path from article.views import ArticleDetailView urlpatterns = [ path('<slug:slug>/', ArticleDetailView.as_view(), name='article-detail'), ] Example myapp/article_detail.html: <h1>{{ object.headline }}</h1> <p>{{ object.content }}</p> <p>Reporter: {{ object.reporter }}</p> <p>Published: {{ object.pub_date|date }}</p> <p>Date: {{ now|date }}</p>
django.ref.class-based-views.generic-display#django.views.generic.detail.DetailView
class django.views.generic.detail.SingleObjectMixin Provides a mechanism for looking up an object associated with the current HTTP request. Methods and Attributes model The model that this view will display data for. Specifying model = Foo is effectively the same as specifying queryset = Foo.objects.all(), where objects stands for Foo’s default manager. queryset A QuerySet that represents the objects. If provided, the value of queryset supersedes the value provided for model. Warning queryset is a class attribute with a mutable value so care must be taken when using it directly. Before using it, either call its all() method or retrieve it with get_queryset() which takes care of the cloning behind the scenes. slug_field The name of the field on the model that contains the slug. By default, slug_field is 'slug'. slug_url_kwarg The name of the URLConf keyword argument that contains the slug. By default, slug_url_kwarg is 'slug'. pk_url_kwarg The name of the URLConf keyword argument that contains the primary key. By default, pk_url_kwarg is 'pk'. context_object_name Designates the name of the variable to use in the context. query_pk_and_slug If True, causes get_object() to perform its lookup using both the primary key and the slug. Defaults to False. This attribute can help mitigate insecure direct object reference attacks. When applications allow access to individual objects by a sequential primary key, an attacker could brute-force guess all URLs; thereby obtaining a list of all objects in the application. If users with access to individual objects should be prevented from obtaining this list, setting query_pk_and_slug to True will help prevent the guessing of URLs as each URL will require two correct, non-sequential arguments. Using a unique slug may serve the same purpose, but this scheme allows you to have non-unique slugs. get_object(queryset=None) Returns the single object that this view will display. If queryset is provided, that queryset will be used as the source of objects; otherwise, get_queryset() will be used. get_object() looks for a pk_url_kwarg argument in the arguments to the view; if this argument is found, this method performs a primary-key based lookup using that value. If this argument is not found, it looks for a slug_url_kwarg argument, and performs a slug lookup using the slug_field. When query_pk_and_slug is True, get_object() will perform its lookup using both the primary key and the slug. get_queryset() Returns the queryset that will be used to retrieve the object that this view will display. By default, get_queryset() returns the value of the queryset attribute if it is set, otherwise it constructs a QuerySet by calling the all() method on the model attribute’s default manager. get_context_object_name(obj) Return the context variable name that will be used to contain the data that this view is manipulating. If context_object_name is not set, the context name will be constructed from the model_name of the model that the queryset is composed from. For example, the model Article would have context object named 'article'. get_context_data(**kwargs) Returns context data for displaying the object. The base implementation of this method requires that the self.object attribute be set by the view (even if None). Be sure to do this if you are using this mixin without one of the built-in views that does so. It returns a dictionary with these contents: object: The object that this view is displaying (self.object). context_object_name: self.object will also be stored under the name returned by get_context_object_name(), which defaults to the lowercased version of the model name. Context variables override values from template context processors Any variables from get_context_data() take precedence over context variables from context processors. For example, if your view sets the model attribute to User, the default context object name of user would override the user variable from the django.contrib.auth.context_processors.auth() context processor. Use get_context_object_name() to avoid a clash. get_slug_field() Returns the name of a slug field to be used to look up by slug. By default this returns the value of slug_field.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin
context_object_name Designates the name of the variable to use in the context.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.context_object_name
get_context_data(**kwargs) Returns context data for displaying the object. The base implementation of this method requires that the self.object attribute be set by the view (even if None). Be sure to do this if you are using this mixin without one of the built-in views that does so. It returns a dictionary with these contents: object: The object that this view is displaying (self.object). context_object_name: self.object will also be stored under the name returned by get_context_object_name(), which defaults to the lowercased version of the model name. Context variables override values from template context processors Any variables from get_context_data() take precedence over context variables from context processors. For example, if your view sets the model attribute to User, the default context object name of user would override the user variable from the django.contrib.auth.context_processors.auth() context processor. Use get_context_object_name() to avoid a clash.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.get_context_data
get_context_object_name(obj) Return the context variable name that will be used to contain the data that this view is manipulating. If context_object_name is not set, the context name will be constructed from the model_name of the model that the queryset is composed from. For example, the model Article would have context object named 'article'.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.get_context_object_name
get_object(queryset=None) Returns the single object that this view will display. If queryset is provided, that queryset will be used as the source of objects; otherwise, get_queryset() will be used. get_object() looks for a pk_url_kwarg argument in the arguments to the view; if this argument is found, this method performs a primary-key based lookup using that value. If this argument is not found, it looks for a slug_url_kwarg argument, and performs a slug lookup using the slug_field. When query_pk_and_slug is True, get_object() will perform its lookup using both the primary key and the slug.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.get_object
get_queryset() Returns the queryset that will be used to retrieve the object that this view will display. By default, get_queryset() returns the value of the queryset attribute if it is set, otherwise it constructs a QuerySet by calling the all() method on the model attribute’s default manager.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.get_queryset
get_slug_field() Returns the name of a slug field to be used to look up by slug. By default this returns the value of slug_field.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.get_slug_field
model The model that this view will display data for. Specifying model = Foo is effectively the same as specifying queryset = Foo.objects.all(), where objects stands for Foo’s default manager.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.model
pk_url_kwarg The name of the URLConf keyword argument that contains the primary key. By default, pk_url_kwarg is 'pk'.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.pk_url_kwarg
query_pk_and_slug If True, causes get_object() to perform its lookup using both the primary key and the slug. Defaults to False. This attribute can help mitigate insecure direct object reference attacks. When applications allow access to individual objects by a sequential primary key, an attacker could brute-force guess all URLs; thereby obtaining a list of all objects in the application. If users with access to individual objects should be prevented from obtaining this list, setting query_pk_and_slug to True will help prevent the guessing of URLs as each URL will require two correct, non-sequential arguments. Using a unique slug may serve the same purpose, but this scheme allows you to have non-unique slugs.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.query_pk_and_slug
queryset A QuerySet that represents the objects. If provided, the value of queryset supersedes the value provided for model. Warning queryset is a class attribute with a mutable value so care must be taken when using it directly. Before using it, either call its all() method or retrieve it with get_queryset() which takes care of the cloning behind the scenes.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.queryset
slug_field The name of the field on the model that contains the slug. By default, slug_field is 'slug'.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.slug_field
slug_url_kwarg The name of the URLConf keyword argument that contains the slug. By default, slug_url_kwarg is 'slug'.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectMixin.slug_url_kwarg
class django.views.generic.detail.SingleObjectTemplateResponseMixin A mixin class that performs template-based response rendering for views that operate upon a single object instance. Requires that the view it is mixed with provides self.object, the object instance that the view is operating on. self.object will usually be, but is not required to be, an instance of a Django model. It may be None if the view is in the process of constructing a new instance. Extends TemplateResponseMixin Methods and Attributes template_name_field The field on the current object instance that can be used to determine the name of a candidate template. If either template_name_field itself or the value of the template_name_field on the current object instance is None, the object will not be used for a candidate template name. template_name_suffix The suffix to append to the auto-generated candidate template name. Default suffix is _detail. get_template_names() Returns a list of candidate template names. Returns the following list: the value of template_name on the view (if provided) the contents of the template_name_field field on the object instance that the view is operating upon (if available) <app_label>/<model_name><template_name_suffix>.html
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectTemplateResponseMixin
get_template_names() Returns a list of candidate template names. Returns the following list: the value of template_name on the view (if provided) the contents of the template_name_field field on the object instance that the view is operating upon (if available) <app_label>/<model_name><template_name_suffix>.html
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectTemplateResponseMixin.get_template_names
template_name_field The field on the current object instance that can be used to determine the name of a candidate template. If either template_name_field itself or the value of the template_name_field on the current object instance is None, the object will not be used for a candidate template name.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectTemplateResponseMixin.template_name_field
template_name_suffix The suffix to append to the auto-generated candidate template name. Default suffix is _detail.
django.ref.class-based-views.mixins-single-object#django.views.generic.detail.SingleObjectTemplateResponseMixin.template_name_suffix
class django.views.generic.edit.BaseCreateView A base view for creating a new object instance. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.CreateView. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.edit.ModelFormMixin django.views.generic.edit.ProcessFormView Methods get(request, *args, **kwargs) Sets the current object instance (self.object) to None. post(request, *args, **kwargs) Sets the current object instance (self.object) to None.
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseCreateView
get(request, *args, **kwargs) Sets the current object instance (self.object) to None.
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseCreateView.get
post(request, *args, **kwargs) Sets the current object instance (self.object) to None.
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseCreateView.post
class django.views.generic.edit.BaseDeleteView A base view for deleting an object instance. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.DeleteView. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.edit.DeletionMixin django.views.generic.edit.FormMixin django.views.generic.detail.BaseDetailView Changed in Django 4.0: In older versions, BaseDeleteView does not inherit from FormMixin.
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseDeleteView
class django.views.generic.edit.BaseFormView A base view for displaying a form. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.FormView or other views displaying a form. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.edit.FormMixin django.views.generic.edit.ProcessFormView
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseFormView
class django.views.generic.edit.BaseUpdateView A base view for updating an existing object instance. It is not intended to be used directly, but rather as a parent class of the django.views.generic.edit.UpdateView. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.edit.ModelFormMixin django.views.generic.edit.ProcessFormView Methods get(request, *args, **kwargs) Sets the current object instance (self.object). post(request, *args, **kwargs) Sets the current object instance (self.object).
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseUpdateView
get(request, *args, **kwargs) Sets the current object instance (self.object).
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseUpdateView.get
post(request, *args, **kwargs) Sets the current object instance (self.object).
django.ref.class-based-views.generic-editing#django.views.generic.edit.BaseUpdateView.post
class django.views.generic.edit.CreateView A view that displays a form for creating an object, redisplaying the form with validation errors (if there are any) and saving the object. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseCreateView django.views.generic.edit.ModelFormMixin django.views.generic.edit.FormMixin django.views.generic.detail.SingleObjectMixin django.views.generic.edit.ProcessFormView django.views.generic.base.View Attributes template_name_suffix The CreateView page displayed to a GET request uses a template_name_suffix of '_form'. For example, changing this attribute to '_create_form' for a view creating objects for the example Author model would cause the default template_name to be 'myapp/author_create_form.html'. object When using CreateView you have access to self.object, which is the object being created. If the object hasn’t been created yet, the value will be None. Example myapp/views.py: from django.views.generic.edit import CreateView from myapp.models import Author class AuthorCreateView(CreateView): model = Author fields = ['name'] Example myapp/author_form.html: <form method="post">{% csrf_token %} {{ form.as_p }} <input type="submit" value="Save"> </form>
django.ref.class-based-views.generic-editing#django.views.generic.edit.CreateView
object When using CreateView you have access to self.object, which is the object being created. If the object hasn’t been created yet, the value will be None.
django.ref.class-based-views.generic-editing#django.views.generic.edit.CreateView.object
template_name_suffix The CreateView page displayed to a GET request uses a template_name_suffix of '_form'. For example, changing this attribute to '_create_form' for a view creating objects for the example Author model would cause the default template_name to be 'myapp/author_create_form.html'.
django.ref.class-based-views.generic-editing#django.views.generic.edit.CreateView.template_name_suffix
class django.views.generic.edit.DeleteView A view that displays a confirmation page and deletes an existing object. The given object will only be deleted if the request method is POST. If this view is fetched via GET, it will display a confirmation page that should contain a form that POSTs to the same URL. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseDeleteView django.views.generic.edit.DeletionMixin django.views.generic.edit.FormMixin django.views.generic.base.ContextMixin django.views.generic.detail.BaseDetailView django.views.generic.detail.SingleObjectMixin django.views.generic.base.View Attributes form_class New in Django 4.0. Inherited from BaseDeleteView. The form class that will be used to confirm the request. By default django.forms.Form, resulting in an empty form that is always valid. By providing your own Form subclass, you can add additional requirements, such as a confirmation checkbox, for example. template_name_suffix The DeleteView page displayed to a GET request uses a template_name_suffix of '_confirm_delete'. For example, changing this attribute to '_check_delete' for a view deleting objects for the example Author model would cause the default template_name to be 'myapp/author_check_delete.html'. Example myapp/views.py: from django.urls import reverse_lazy from django.views.generic.edit import DeleteView from myapp.models import Author class AuthorDeleteView(DeleteView): model = Author success_url = reverse_lazy('author-list') Example myapp/author_confirm_delete.html: <form method="post">{% csrf_token %} <p>Are you sure you want to delete "{{ object }}"?</p> {{ form }} <input type="submit" value="Confirm"> </form>
django.ref.class-based-views.generic-editing#django.views.generic.edit.DeleteView
form_class New in Django 4.0. Inherited from BaseDeleteView. The form class that will be used to confirm the request. By default django.forms.Form, resulting in an empty form that is always valid. By providing your own Form subclass, you can add additional requirements, such as a confirmation checkbox, for example.
django.ref.class-based-views.generic-editing#django.views.generic.edit.DeleteView.form_class
template_name_suffix The DeleteView page displayed to a GET request uses a template_name_suffix of '_confirm_delete'. For example, changing this attribute to '_check_delete' for a view deleting objects for the example Author model would cause the default template_name to be 'myapp/author_check_delete.html'.
django.ref.class-based-views.generic-editing#django.views.generic.edit.DeleteView.template_name_suffix
class django.views.generic.edit.DeletionMixin Enables handling of the DELETE HTTP action. Methods and Attributes success_url The url to redirect to when the nominated object has been successfully deleted. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/parent/{parent_id}/" to redirect to a URL composed out of the parent_id field on a model. delete(request, *args, **kwargs) Retrieves the target object and calls its delete() method, then redirects to the success URL. get_success_url() Returns the url to redirect to when the nominated object has been successfully deleted. Returns success_url by default.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.DeletionMixin
delete(request, *args, **kwargs) Retrieves the target object and calls its delete() method, then redirects to the success URL.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.DeletionMixin.delete
get_success_url() Returns the url to redirect to when the nominated object has been successfully deleted. Returns success_url by default.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.DeletionMixin.get_success_url
success_url The url to redirect to when the nominated object has been successfully deleted. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/parent/{parent_id}/" to redirect to a URL composed out of the parent_id field on a model.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.DeletionMixin.success_url
class django.views.generic.edit.FormMixin A mixin class that provides facilities for creating and displaying forms. Mixins django.views.generic.base.ContextMixin Methods and Attributes initial A dictionary containing initial data for the form. form_class The form class to instantiate. success_url The URL to redirect to when the form is successfully processed. prefix The prefix for the generated form. get_initial() Retrieve initial data for the form. By default, returns a copy of initial. get_form_class() Retrieve the form class to instantiate. By default form_class. get_form(form_class=None) Instantiate an instance of form_class using get_form_kwargs(). If form_class isn’t provided get_form_class() will be used. get_form_kwargs() Build the keyword arguments required to instantiate the form. The initial argument is set to get_initial(). If the request is a POST or PUT, the request data (request.POST and request.FILES) will also be provided. get_prefix() Determine the prefix for the generated form. Returns prefix by default. get_success_url() Determine the URL to redirect to when the form is successfully validated. Returns success_url by default. form_valid(form) Redirects to get_success_url(). form_invalid(form) Renders a response, providing the invalid form as context. get_context_data(**kwargs) Calls get_form() and adds the result to the context data with the name ‘form’.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin
form_class The form class to instantiate.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.form_class
form_invalid(form) Renders a response, providing the invalid form as context.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.form_invalid
form_valid(form) Redirects to get_success_url().
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.form_valid
get_context_data(**kwargs) Calls get_form() and adds the result to the context data with the name ‘form’.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.get_context_data
get_form(form_class=None) Instantiate an instance of form_class using get_form_kwargs(). If form_class isn’t provided get_form_class() will be used.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.get_form
get_form_class() Retrieve the form class to instantiate. By default form_class.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.get_form_class
get_form_kwargs() Build the keyword arguments required to instantiate the form. The initial argument is set to get_initial(). If the request is a POST or PUT, the request data (request.POST and request.FILES) will also be provided.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.get_form_kwargs
get_initial() Retrieve initial data for the form. By default, returns a copy of initial.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.get_initial
get_prefix() Determine the prefix for the generated form. Returns prefix by default.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.get_prefix
get_success_url() Determine the URL to redirect to when the form is successfully validated. Returns success_url by default.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.get_success_url
initial A dictionary containing initial data for the form.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.initial
prefix The prefix for the generated form.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.prefix
success_url The URL to redirect to when the form is successfully processed.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.FormMixin.success_url
class django.views.generic.edit.FormView A view that displays a form. On error, redisplays the form with validation errors; on success, redirects to a new URL. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseFormView django.views.generic.edit.FormMixin django.views.generic.edit.ProcessFormView django.views.generic.base.View Example myapp/forms.py: from django import forms class ContactForm(forms.Form): name = forms.CharField() message = forms.CharField(widget=forms.Textarea) def send_email(self): # send email using the self.cleaned_data dictionary pass Example myapp/views.py: from myapp.forms import ContactForm from django.views.generic.edit import FormView class ContactFormView(FormView): template_name = 'contact.html' form_class = ContactForm success_url = '/thanks/' def form_valid(self, form): # This method is called when valid form data has been POSTed. # It should return an HttpResponse. form.send_email() return super().form_valid(form) Example myapp/contact.html: <form method="post">{% csrf_token %} {{ form.as_p }} <input type="submit" value="Send message"> </form>
django.ref.class-based-views.generic-editing#django.views.generic.edit.FormView
class django.views.generic.edit.ModelFormMixin A form mixin that works on ModelForms, rather than a standalone form. Since this is a subclass of SingleObjectMixin, instances of this mixin have access to the model and queryset attributes, describing the type of object that the ModelForm is manipulating. If you specify both the fields and form_class attributes, an ImproperlyConfigured exception will be raised. Mixins django.views.generic.edit.FormMixin django.views.generic.detail.SingleObjectMixin Methods and Attributes model A model class. Can be explicitly provided, otherwise will be determined by examining self.object or queryset. fields A list of names of fields. This is interpreted the same way as the Meta.fields attribute of ModelForm. This is a required attribute if you are generating the form class automatically (e.g. using model). Omitting this attribute will result in an ImproperlyConfigured exception. success_url The URL to redirect to when the form is successfully processed. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/polls/{slug}/" to redirect to a URL composed out of the slug field on a model. get_form_class() Retrieve the form class to instantiate. If form_class is provided, that class will be used. Otherwise, a ModelForm will be instantiated using the model associated with the queryset, or with the model, depending on which attribute is provided. get_form_kwargs() Add the current instance (self.object) to the standard get_form_kwargs(). get_success_url() Determine the URL to redirect to when the form is successfully validated. Returns django.views.generic.edit.ModelFormMixin.success_url if it is provided; otherwise, attempts to use the get_absolute_url() of the object. form_valid(form) Saves the form instance, sets the current object for the view, and redirects to get_success_url(). form_invalid(form) Renders a response, providing the invalid form as context.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin
fields A list of names of fields. This is interpreted the same way as the Meta.fields attribute of ModelForm. This is a required attribute if you are generating the form class automatically (e.g. using model). Omitting this attribute will result in an ImproperlyConfigured exception.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.fields
form_invalid(form) Renders a response, providing the invalid form as context.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.form_invalid
form_valid(form) Saves the form instance, sets the current object for the view, and redirects to get_success_url().
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.form_valid
get_form_class() Retrieve the form class to instantiate. If form_class is provided, that class will be used. Otherwise, a ModelForm will be instantiated using the model associated with the queryset, or with the model, depending on which attribute is provided.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.get_form_class
get_form_kwargs() Add the current instance (self.object) to the standard get_form_kwargs().
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.get_form_kwargs
get_success_url() Determine the URL to redirect to when the form is successfully validated. Returns django.views.generic.edit.ModelFormMixin.success_url if it is provided; otherwise, attempts to use the get_absolute_url() of the object.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.get_success_url
model A model class. Can be explicitly provided, otherwise will be determined by examining self.object or queryset.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.model
success_url The URL to redirect to when the form is successfully processed. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/polls/{slug}/" to redirect to a URL composed out of the slug field on a model.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ModelFormMixin.success_url
class django.views.generic.edit.ProcessFormView A mixin that provides basic HTTP GET and POST workflow. Note This is named ‘ProcessFormView’ and inherits directly from django.views.generic.base.View, but breaks if used independently, so it is more of a mixin. Extends django.views.generic.base.View Methods and Attributes get(request, *args, **kwargs) Renders a response using a context created with get_context_data(). post(request, *args, **kwargs) Constructs a form, checks the form for validity, and handles it accordingly. put(*args, **kwargs) The PUT action is also handled and passes all parameters through to post().
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ProcessFormView
get(request, *args, **kwargs) Renders a response using a context created with get_context_data().
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ProcessFormView.get
post(request, *args, **kwargs) Constructs a form, checks the form for validity, and handles it accordingly.
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ProcessFormView.post
put(*args, **kwargs) The PUT action is also handled and passes all parameters through to post().
django.ref.class-based-views.mixins-editing#django.views.generic.edit.ProcessFormView.put
class django.views.generic.edit.UpdateView A view that displays a form for editing an existing object, redisplaying the form with validation errors (if there are any) and saving changes to the object. This uses a form automatically generated from the object’s model class (unless a form class is manually specified). Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.edit.BaseUpdateView django.views.generic.edit.ModelFormMixin django.views.generic.edit.FormMixin django.views.generic.detail.SingleObjectMixin django.views.generic.edit.ProcessFormView django.views.generic.base.View Attributes template_name_suffix The UpdateView page displayed to a GET request uses a template_name_suffix of '_form'. For example, changing this attribute to '_update_form' for a view updating objects for the example Author model would cause the default template_name to be 'myapp/author_update_form.html'. object When using UpdateView you have access to self.object, which is the object being updated. Example myapp/views.py: from django.views.generic.edit import UpdateView from myapp.models import Author class AuthorUpdateView(UpdateView): model = Author fields = ['name'] template_name_suffix = '_update_form' Example myapp/author_update_form.html: <form method="post">{% csrf_token %} {{ form.as_p }} <input type="submit" value="Update"> </form>
django.ref.class-based-views.generic-editing#django.views.generic.edit.UpdateView
object When using UpdateView you have access to self.object, which is the object being updated.
django.ref.class-based-views.generic-editing#django.views.generic.edit.UpdateView.object
template_name_suffix The UpdateView page displayed to a GET request uses a template_name_suffix of '_form'. For example, changing this attribute to '_update_form' for a view updating objects for the example Author model would cause the default template_name to be 'myapp/author_update_form.html'.
django.ref.class-based-views.generic-editing#django.views.generic.edit.UpdateView.template_name_suffix
class django.views.generic.list.BaseListView A base view for displaying a list of objects. It is not intended to be used directly, but rather as a parent class of the django.views.generic.list.ListView or other views representing lists of objects. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.list.MultipleObjectMixin django.views.generic.base.View Methods get(request, *args, **kwargs) Adds object_list to the context. If allow_empty is True then display an empty list. If allow_empty is False then raise a 404 error.
django.ref.class-based-views.generic-display#django.views.generic.list.BaseListView
get(request, *args, **kwargs) Adds object_list to the context. If allow_empty is True then display an empty list. If allow_empty is False then raise a 404 error.
django.ref.class-based-views.generic-display#django.views.generic.list.BaseListView.get
class django.views.generic.list.ListView A page representing a list of objects. While this view is executing, self.object_list will contain the list of objects (usually, but not necessarily a queryset) that the view is operating upon. Ancestors (MRO) This view inherits methods and attributes from the following views: django.views.generic.list.MultipleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.list.BaseListView django.views.generic.list.MultipleObjectMixin django.views.generic.base.View Method Flowchart setup() dispatch() http_method_not_allowed() get_template_names() get_queryset() get_context_object_name() get_context_data() get() render_to_response() Example views.py: from django.utils import timezone from django.views.generic.list import ListView from articles.models import Article class ArticleListView(ListView): model = Article paginate_by = 100 # if pagination is desired def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['now'] = timezone.now() return context Example myapp/urls.py: from django.urls import path from article.views import ArticleListView urlpatterns = [ path('', ArticleListView.as_view(), name='article-list'), ] Example myapp/article_list.html: <h1>Articles</h1> <ul> {% for article in object_list %} <li>{{ article.pub_date|date }} - {{ article.headline }}</li> {% empty %} <li>No articles yet.</li> {% endfor %} </ul> If you’re using pagination, you can adapt the example template from the pagination docs. Change instances of contacts in that example template to page_obj.
django.ref.class-based-views.generic-display#django.views.generic.list.ListView
class django.views.generic.list.MultipleObjectMixin A mixin that can be used to display a list of objects. If paginate_by is specified, Django will paginate the results returned by this. You can specify the page number in the URL in one of two ways: Use the page parameter in the URLconf. For example, this is what your URLconf might look like: path('objects/page<int:page>/', PaginatedView.as_view()), Pass the page number via the page query-string parameter. For example, a URL would look like this: /objects/?page=3 These values and lists are 1-based, not 0-based, so the first page would be represented as page 1. For more on pagination, read the pagination documentation. As a special case, you are also permitted to use last as a value for page: /objects/?page=last This allows you to access the final page of results without first having to determine how many pages there are. Note that page must be either a valid page number or the value last; any other value for page will result in a 404 error. Extends django.views.generic.base.ContextMixin Methods and Attributes allow_empty A boolean specifying whether to display the page if no objects are available. If this is False and no objects are available, the view will raise a 404 instead of displaying an empty page. By default, this is True. model The model that this view will display data for. Specifying model = Foo is effectively the same as specifying queryset = Foo.objects.all(), where objects stands for Foo’s default manager. queryset A QuerySet that represents the objects. If provided, the value of queryset supersedes the value provided for model. Warning queryset is a class attribute with a mutable value so care must be taken when using it directly. Before using it, either call its all() method or retrieve it with get_queryset() which takes care of the cloning behind the scenes. ordering A string or list of strings specifying the ordering to apply to the queryset. Valid values are the same as those for order_by(). paginate_by An integer specifying how many objects should be displayed per page. If this is given, the view will paginate objects with paginate_by objects per page. The view will expect either a page query string parameter (via request.GET) or a page variable specified in the URLconf. paginate_orphans An integer specifying the number of “overflow” objects the last page can contain. This extends the paginate_by limit on the last page by up to paginate_orphans, in order to keep the last page from having a very small number of objects. page_kwarg A string specifying the name to use for the page parameter. The view will expect this parameter to be available either as a query string parameter (via request.GET) or as a kwarg variable specified in the URLconf. Defaults to page. paginator_class The paginator class to be used for pagination. By default, django.core.paginator.Paginator is used. If the custom paginator class doesn’t have the same constructor interface as django.core.paginator.Paginator, you will also need to provide an implementation for get_paginator(). 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). get_ordering() Returns a string (or iterable of strings) that defines the ordering that will be applied to the queryset. Returns ordering by default. paginate_queryset(queryset, page_size) Returns a 4-tuple containing (paginator, page, object_list, is_paginated). Constructed by paginating queryset into pages of size page_size. If the request contains a page argument, either as a captured URL argument or as a GET argument, object_list will correspond to the objects from that page. get_paginate_by(queryset) Returns the number of items to paginate by, or None for no pagination. By default this returns the value of paginate_by. get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True) Returns an instance of the paginator to use for this view. By default, instantiates an instance of paginator_class. get_paginate_orphans() An integer specifying the number of “overflow” objects the last page can contain. By default this returns the value of paginate_orphans. get_allow_empty() Return a boolean specifying whether to display the page if no objects are available. If this method returns False and no objects are available, the view will raise a 404 instead of displaying an empty page. By default, this is True. get_context_object_name(object_list) Return the context variable name that will be used to contain the list of data that this view is manipulating. If object_list is a queryset of Django objects and context_object_name is not set, the context name will be the model_name of the model that the queryset is composed from, with postfix '_list' appended. For example, the model Article would have a context object named article_list. get_context_data(**kwargs) Returns context data for displaying the list of objects. Context object_list: The list of objects that this view is displaying. If context_object_name is specified, that variable will also be set in the context, with the same value as object_list. is_paginated: A boolean representing whether the results are paginated. Specifically, this is set to False if no page size has been specified, or if the available objects do not span multiple pages. paginator: An instance of django.core.paginator.Paginator. If the page is not paginated, this context variable will be None. page_obj: An instance of django.core.paginator.Page. If the page is not paginated, this context variable will be None.
django.ref.class-based-views.mixins-multiple-object#django.views.generic.list.MultipleObjectMixin
allow_empty A boolean specifying whether to display the page if no objects are available. If this is False and no objects are available, the view will raise a 404 instead of displaying an empty page. By default, this is True.
django.ref.class-based-views.mixins-multiple-object#django.views.generic.list.MultipleObjectMixin.allow_empty
context_object_name Designates the name of the variable to use in the context.
django.ref.class-based-views.mixins-multiple-object#django.views.generic.list.MultipleObjectMixin.context_object_name
get_allow_empty() Return a boolean specifying whether to display the page if no objects are available. If this method returns False and no objects are available, the view will raise a 404 instead of displaying an empty page. By default, this is True.
django.ref.class-based-views.mixins-multiple-object#django.views.generic.list.MultipleObjectMixin.get_allow_empty
get_context_data(**kwargs) Returns context data for displaying the list of objects.
django.ref.class-based-views.mixins-multiple-object#django.views.generic.list.MultipleObjectMixin.get_context_data
get_context_object_name(object_list) Return the context variable name that will be used to contain the list of data that this view is manipulating. If object_list is a queryset of Django objects and context_object_name is not set, the context name will be the model_name of the model that the queryset is composed from, with postfix '_list' appended. For example, the model Article would have a context object named article_list.
django.ref.class-based-views.mixins-multiple-object#django.views.generic.list.MultipleObjectMixin.get_context_object_name
get_ordering() Returns a string (or iterable of strings) that defines the ordering that will be applied to the queryset. Returns ordering by default.
django.ref.class-based-views.mixins-multiple-object#django.views.generic.list.MultipleObjectMixin.get_ordering