2010-10-18 21:34:47 +08:00
|
|
|
=========================
|
2010-10-19 00:35:37 +08:00
|
|
|
Class-based generic views
|
2010-10-18 21:34:47 +08:00
|
|
|
=========================
|
|
|
|
|
|
|
|
.. versionadded:: 1.3
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
Prior to Django 1.3, generic views were implemented as functions. The
|
|
|
|
function-based implementation has been deprecated in favor of the
|
|
|
|
class-based approach described here.
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
For details on the previous generic views implementation,
|
2010-10-18 21:34:47 +08:00
|
|
|
see the :doc:`topic guide </topics/generic-views>` and
|
2010-10-19 07:26:16 +08:00
|
|
|
:doc:`detailed reference </ref/generic-views>`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
Writing Web applications can be monotonous, because we repeat certain patterns
|
2010-10-19 07:09:13 +08:00
|
|
|
again and again. Django tries to take away some of that monotony at the model
|
|
|
|
and template layers, but Web developers also experience this boredom at the view
|
|
|
|
level.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
A general introduction to class-based generic views can be found in the
|
|
|
|
:doc:`topic guide </topics/class-based-views>`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
This reference contains details of Django's built-in generic views, along with
|
2010-10-19 07:09:13 +08:00
|
|
|
a list of the keyword arguments that each generic view expects. Remember that
|
2010-10-18 21:34:47 +08:00
|
|
|
arguments may either come from the URL pattern or from the ``extra_context``
|
|
|
|
additional-information dictionary.
|
|
|
|
|
|
|
|
Most generic views require the ``queryset`` key, which is a ``QuerySet``
|
|
|
|
instance; see :doc:`/topics/db/queries` for more information about ``QuerySet``
|
|
|
|
objects.
|
|
|
|
|
|
|
|
Mixins
|
|
|
|
======
|
|
|
|
|
|
|
|
A mixin class is a way of using the inheritance capabilities of
|
|
|
|
classes to compose a class out of smaller pieces of behavior. Django's
|
2010-10-19 07:09:13 +08:00
|
|
|
class-based generic views are constructed by composing mixins into
|
2010-10-18 21:34:47 +08:00
|
|
|
usable generic views.
|
|
|
|
|
|
|
|
For example, the :class:`~django.views.generic.base.detail.DetailView`
|
|
|
|
is composed from:
|
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`~django.db.views.generic.base.View`, which provides the
|
|
|
|
basic class-based behavior
|
|
|
|
* :class:`~django.db.views.generic.detail.SingleObjectMixin`, which
|
|
|
|
provides the utilities for retrieving and displaying a single object
|
|
|
|
* :class:`~django.db.views.generic.detail.SingleObjectTemplateResponseMixin`,
|
|
|
|
which provides the tools for rendering a single object into a
|
|
|
|
template-based response.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
When combined, these mixins provide all the pieces necessary to
|
|
|
|
provide a view over a single object that renders a template to produce
|
|
|
|
a response.
|
|
|
|
|
|
|
|
Django provides a range of mixins. If you want to write your own
|
|
|
|
generic views, you can build classes that compose these mixins in
|
|
|
|
interesting ways. Alternatively, you can just use the pre-mixed
|
|
|
|
`Generic views`_ that Django provides.
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
When the documentation for a view gives the list of mixins, that view
|
|
|
|
inherits all the properties and methods of that mixin.
|
|
|
|
|
2010-10-18 21:34:47 +08:00
|
|
|
Simple mixins
|
|
|
|
-------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.base
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
TemplateResponseMixin
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: TemplateResponseMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: template_name
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The path to the template to use when rendering the view.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-07 21:57:01 +08:00
|
|
|
.. attribute:: response_class
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-07 21:57:01 +08:00
|
|
|
The response class to be returned by ``render_to_response`` method.
|
|
|
|
Default is
|
|
|
|
:class:`TemplateResponse <django.template.response.TemplateResponse>`.
|
2011-05-22 08:08:13 +08:00
|
|
|
The template and context of ``TemplateResponse`` instances can be
|
2010-12-07 21:57:01 +08:00
|
|
|
altered later (e.g. in
|
|
|
|
:ref:`template response middleware <template-response-middleware>`).
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-05-22 08:08:13 +08:00
|
|
|
If you need custom template loading or custom context object
|
|
|
|
instantiation, create a ``TemplateResponse`` subclass and assign it to
|
|
|
|
``response_class``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-07 21:57:01 +08:00
|
|
|
.. method:: render_to_response(context, **response_kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-05-22 08:08:13 +08:00
|
|
|
Returns a ``self.response_class`` instance.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-07 21:57:01 +08:00
|
|
|
If any keyword arguments are provided, they will be
|
2011-05-22 08:08:13 +08:00
|
|
|
passed to the constructor of the response class.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Calls :meth:`~TemplateResponseMixin.get_template_names()` to obtain the
|
|
|
|
list of template names that will be searched looking for an existent
|
|
|
|
template.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_template_names()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
Returns a list of template names to search for when rendering the
|
|
|
|
template.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
If :attr:`TemplateResponseMixin.template_name` is specified, the
|
|
|
|
default implementation will return a list containing
|
|
|
|
:attr:`TemplateResponseMixin.template_name` (if it is specified).
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
Single object mixins
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.detail
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
SingleObjectMixin
|
|
|
|
~~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: SingleObjectMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: model
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The model that this view will display data for. Specifying ``model
|
|
|
|
= Foo`` is effectively the same as specifying ``queryset =
|
|
|
|
Foo.objects.all()``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: queryset
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A ``QuerySet`` that represents the objects. If provided, the value of
|
|
|
|
:attr:`SingleObjectMixin.queryset` supersedes the value provided for
|
|
|
|
:attr:`SingleObjectMixin.model`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: slug_field
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The name of the field on the model that contains the slug. By default,
|
|
|
|
``slug_field`` is ``'slug'``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-07-29 17:41:00 +08:00
|
|
|
.. attribute:: slug_url_kwarg
|
|
|
|
|
|
|
|
.. versionadded:: 1.4
|
|
|
|
|
|
|
|
The name of the URLConf keyword argument that contains the slug. By
|
|
|
|
default, ``slug_url_kwarg`` is ``'slug'``.
|
|
|
|
|
|
|
|
.. attribute:: pk_url_kwarg
|
|
|
|
|
|
|
|
.. versionadded:: 1.4
|
|
|
|
|
|
|
|
The name of the URLConf keyword argument that contains the primary key.
|
|
|
|
By default, ``pk_url_kwarg`` is ``'pk'``.
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: context_object_name
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Designates the name of the variable to use in the context.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-20 08:21:47 +08:00
|
|
|
.. method:: 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,
|
|
|
|
:meth:`~SingleObjectMixin.get_queryset` will be used.
|
2011-07-29 17:41:00 +08:00
|
|
|
``get_object()`` looks for a
|
|
|
|
:attr:`SingleObjectMixin.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 :attr:`SingleObjectMixin.slug_url_kwarg`
|
2010-10-20 08:21:47 +08:00
|
|
|
argument, and performs a slug lookup using the
|
|
|
|
:attr:`SingleObjectMixin.slug_field`.
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_queryset()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
Returns the queryset that will be used to retrieve the object that
|
|
|
|
this view will display. By default,
|
|
|
|
:meth:`~SingleObjectMixin.get_queryset` returns the value of the
|
|
|
|
:attr:`~SingleObjectMixin.queryset` attribute if it is set, otherwise
|
|
|
|
it constructs a :class:`QuerySet` by calling the `all()` method on the
|
|
|
|
:attr:`~SingleObjectMixin.model` attribute's default manager.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-02-14 21:04:51 +08:00
|
|
|
.. method:: get_context_object_name(obj)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
Return the context variable name that will be used to contain the
|
2011-02-14 21:04:51 +08:00
|
|
|
data that this view is manipulating. If
|
2010-10-19 07:09:13 +08:00
|
|
|
:attr:`~SingleObjectMixin.context_object_name` is not set, the context
|
2011-02-14 21:04:51 +08:00
|
|
|
name will be constructed from the ``object_name`` of the model that
|
|
|
|
the queryset is composed from. For example, the model ``Article``
|
|
|
|
would have context object named ``'article'``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_context_data(**kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns context data for displaying the list of objects.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``object``: The object 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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
SingleObjectTemplateResponseMixin
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: SingleObjectTemplateResponseMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Extends**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`~django.views.generic.base.TemplateResponseMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: template_name_field
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The field on the current object instance that can be used to determine
|
|
|
|
the name of a candidate template. If either ``template_name_field`` or
|
|
|
|
the value of the ``template_name_field`` on the current object instance
|
|
|
|
is ``None``, the object will not be interrogated for a candidate
|
|
|
|
template name.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: template_name_suffix
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The suffix to append to the auto-generated candidate template name.
|
|
|
|
Default suffix is ``_detail``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_template_names()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a list of candidate template names. Returns the following list:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* 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>/<object_name><template_name_suffix>.html``
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
Multiple object mixins
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.list
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
MultipleObjectMixin
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: MultipleObjectMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin that can be used to display a list of objects.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Use the ``page`` parameter in the URLconf. For example, this is what
|
|
|
|
your URLconf might look like::
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
(r'^objects/page(?P<page>[0-9]+)/$', PaginatedView.as_view())
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Pass the page number via the ``page`` query-string parameter. For
|
|
|
|
example, a URL would look like this::
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
/objects/?page=3
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
These values and lists are 1-based, not 0-based, so the first page would be
|
|
|
|
represented as page ``1``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
For more on pagination, read the :doc:`pagination documentation
|
|
|
|
</topics/pagination>`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
As a special case, you are also permitted to use ``last`` as a value for
|
|
|
|
``page``::
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
/objects/?page=last
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
This allows you to access the final page of results without first having to
|
|
|
|
determine how many pages there are.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: allow_empty
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: model
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The model that this view will display data for. Specifying ``model
|
|
|
|
= Foo`` is effectively the same as specifying ``queryset =
|
|
|
|
Foo.objects.all()``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: queryset
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A ``QuerySet`` that represents the objects. If provided, the value of
|
|
|
|
:attr:`MultipleObjectMixin.queryset` supersedes the value provided for
|
|
|
|
:attr:`MultipleObjectMixin.model`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: paginate_by
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
An integer specifying how many objects should be displayed per page. If
|
|
|
|
this is given, the view will paginate objects with
|
|
|
|
:attr:`MultipleObjectMixin.paginate_by` objects per page. The view will
|
|
|
|
expect either a ``page`` query string parameter (via ``GET``) or a
|
|
|
|
``page`` variable specified in the URLconf.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-05 12:32:36 +08:00
|
|
|
.. attribute:: paginator_class
|
|
|
|
|
|
|
|
The paginator class to be used for pagination. By default,
|
|
|
|
:class:`django.core.paginator.Paginator` is used. If the custom paginator
|
|
|
|
class doesn't have the same constructor interface as
|
|
|
|
:class:`django.core.paginator.Paginator`, you will also need to
|
|
|
|
provide an implementation for :meth:`MultipleObjectMixin.get_paginator`.
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: context_object_name
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Designates the name of the variable to use in the context.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_queryset()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the queryset that represents the data this view will display.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: paginate_queryset(queryset, page_size)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a 4-tuple containing (``paginator``, ``page``, ``object_list``,
|
|
|
|
``is_paginated``).
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_paginate_by(queryset)
|
2010-10-20 08:21:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
Returns the number of items to paginate by, or ``None`` for no
|
|
|
|
pagination. By default this simply returns the value of
|
|
|
|
:attr:`MultipleObjectMixin.paginate_by`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-15 07:34:47 +08:00
|
|
|
.. method:: get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True)
|
2010-12-05 12:32:36 +08:00
|
|
|
|
|
|
|
Returns an instance of the paginator to use for this view. By default,
|
|
|
|
instantiates an instance of :attr:`paginator_class`.
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_allow_empty()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_context_object_name(object_list)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-02-14 21:04:51 +08:00
|
|
|
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
|
|
|
|
:attr:`~MultipleObjectMixin.context_object_name` is not set,
|
|
|
|
the context name will be the ``object_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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_context_data(**kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns context data for displaying the list of objects.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``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.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``paginator``: An instance of
|
|
|
|
:class:`django.core.paginator.Paginator`. If the page is not
|
|
|
|
paginated, this context variable will be ``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``page_obj``: An instance of
|
|
|
|
:class:`django.core.paginator.Page`. If the page is not paginated,
|
|
|
|
this context variable will be ``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
MultipleObjectTemplateResponseMixin
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: MultipleObjectTemplateResponseMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin class that performs template-based response rendering for views
|
|
|
|
that operate upon a list of object instances. Requires that the view it is
|
|
|
|
mixed with provides ``self.object_list``, the list of object instances that
|
|
|
|
the view is operating on. ``self.object_list`` may be, but is not required
|
2011-09-30 18:28:39 +08:00
|
|
|
to be, a :class:`~django.db.models.query.QuerySet`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Extends**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`~django.views.generic.base.TemplateResponseMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: template_name_suffix
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The suffix to append to the auto-generated candidate template name.
|
|
|
|
Default suffix is ``_list``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_template_names()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a list of candidate template names. Returns the following list:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* the value of ``template_name`` on the view (if provided)
|
|
|
|
* ``<app_label>/<object_name><template_name_suffix>.html``
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
Editing mixins
|
|
|
|
--------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.edit
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
FormMixin
|
|
|
|
~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: FormMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin class that provides facilities for creating and displaying forms.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: initial
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A dictionary containing initial data for the form.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: form_class
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The form class to instantiate.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: success_url
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The URL to redirect to when the form is successfully processed.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_initial()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2012-03-18 06:31:03 +08:00
|
|
|
Retrieve initial data for the form. By default, returns a copy of
|
2010-12-10 11:51:30 +08:00
|
|
|
:attr:`.initial`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2012-03-18 06:31:03 +08:00
|
|
|
.. admonition:: Changed in 1.4
|
|
|
|
|
|
|
|
In Django 1.3, this method was returning the :attr:`initial` class
|
|
|
|
variable itself.
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_form_class()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-10 11:51:30 +08:00
|
|
|
Retrieve the form class to instantiate. By default
|
|
|
|
:attr:`.form_class`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_form(form_class)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-10 11:51:30 +08:00
|
|
|
Instantiate an instance of ``form_class`` using
|
|
|
|
:meth:`.get_form_kwargs`.
|
|
|
|
|
|
|
|
.. method:: get_form_kwargs()
|
|
|
|
|
2011-05-31 17:42:19 +08:00
|
|
|
Build the keyword arguments required to instantiate the form.
|
2011-01-03 21:15:58 +08:00
|
|
|
|
2010-12-10 11:51:30 +08:00
|
|
|
The ``initial`` argument is set to :meth:`.get_initial`. If the
|
|
|
|
request is a ``POST`` or ``PUT``, the request data (``request.POST``
|
|
|
|
and ``request.FILES``) will also be provided.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_success_url()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Determine the URL to redirect to when the form is successfully
|
2010-12-10 11:51:30 +08:00
|
|
|
validated. Returns :attr:`.success_url` by default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-03-23 06:01:27 +08:00
|
|
|
.. method:: form_valid(form)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-10 11:51:30 +08:00
|
|
|
Redirects to :meth:`.get_success_url`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-03-23 06:01:27 +08:00
|
|
|
.. method:: form_invalid(form)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Renders a response, providing the invalid form as context.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_context_data(**kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Populates a context containing the contents of ``kwargs``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``form``: The form instance that was generated for the view.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
.. note::
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-10 11:51:30 +08:00
|
|
|
Views mixing :class:`FormMixin` must
|
|
|
|
provide an implementation of :meth:`.form_valid` and
|
|
|
|
:meth:`.form_invalid`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
ModelFormMixin
|
|
|
|
~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: ModelFormMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A form mixin that works on ModelForms, rather than a standalone form.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Since this is a subclass of
|
|
|
|
:class:`~django.views.generic.detail.SingleObjectMixin`, instances of this
|
2010-11-26 10:56:58 +08:00
|
|
|
mixin have access to the :attr:`~SingleObjectMixin.model` and
|
|
|
|
:attr:`~SingleObjectMixin.queryset` attributes, describing the type of
|
2010-10-19 05:39:30 +08:00
|
|
|
object that the ModelForm is manipulating. The view also provides
|
|
|
|
``self.object``, the instance being manipulated. If the instance is being
|
2011-11-05 00:33:18 +08:00
|
|
|
created, ``self.object`` will be ``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.edit.FormMixin`
|
|
|
|
* :class:`django.views.generic.detail.SingleObjectMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: success_url
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The URL to redirect to when the form is successfully processed.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-04 19:20:30 +08:00
|
|
|
``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)s/"`` to
|
|
|
|
redirect to a URL composed out of the ``slug`` field on a model.
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_form_class()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Retrieve the form class to instantiate. If
|
|
|
|
:attr:`FormMixin.form_class` is provided, that class will be used.
|
|
|
|
Otherwise, a ModelForm will be instantiated using the model associated
|
2010-11-26 10:56:58 +08:00
|
|
|
with the :attr:`~SingleObjectMixin.queryset`, or with the
|
|
|
|
:attr:`~SingleObjectMixin.model`, depending on which attribute is
|
2010-10-19 05:39:30 +08:00
|
|
|
provided.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-10 11:51:30 +08:00
|
|
|
.. method:: get_form_kwargs()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-12-10 11:51:30 +08:00
|
|
|
Add the current instance (``self.object``) to the standard
|
|
|
|
:meth:`FormMixin.get_form_kwargs`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_success_url()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Determine the URL to redirect to when the form is successfully
|
|
|
|
validated. Returns :attr:`FormMixin.success_url` if it is provided;
|
|
|
|
otherwise, attempts to use the ``get_absolute_url()`` of the object.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-11-05 00:33:18 +08:00
|
|
|
.. method:: form_valid(form)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Saves the form instance, sets the current object for the view, and
|
2010-12-10 11:51:30 +08:00
|
|
|
redirects to :meth:`.get_success_url`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: form_invalid()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Renders a response, providing the invalid form as context.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
ProcessFormView
|
|
|
|
~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: ProcessFormView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin that provides basic HTTP GET and POST workflow.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
.. method:: get(request, *args, **kwargs)
|
2010-10-20 08:21:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
Constructs a form, then renders a response using a context that
|
|
|
|
contains that form.
|
|
|
|
|
|
|
|
.. method:: post(request, *args, **kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
Constructs a form, checks the form for validity, and handles it
|
|
|
|
accordingly.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The PUT action is also handled, as an analog of POST.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
DeletionMixin
|
|
|
|
~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: DeletionMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Enables handling of the ``DELETE`` http action.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: success_url
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The url to redirect to when the nominated object has been
|
|
|
|
successfully deleted.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
.. method:: get_success_url(obj)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the url to redirect to when the nominated object has been
|
|
|
|
successfully deleted. Returns
|
|
|
|
:attr:`~django.views.generic.edit.DeletionMixin.success_url` by
|
|
|
|
default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
Date-based mixins
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.dates
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
YearMixin
|
|
|
|
~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: YearMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin that can be used to retrieve and provide parsing information for a
|
|
|
|
year component of a date.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: year_format
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
The :func:`~time.strftime` format to use when parsing the year.
|
|
|
|
By default, this is ``'%Y'``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: year
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Optional** The value for the year (as a string). By default, set to
|
|
|
|
``None``, which means the year will be determined using other means.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_year_format()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
Returns the :func:`~time.strftime` format to use when parsing the year. Returns
|
2010-10-19 05:39:30 +08:00
|
|
|
:attr:`YearMixin.year_format` by default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_year()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the year for which this view will display data. Tries the
|
|
|
|
following sources, in order:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* The value of the :attr:`YearMixin.year` attribute.
|
|
|
|
* The value of the `year` argument captured in the URL pattern
|
|
|
|
* The value of the `year` GET query argument.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Raises a 404 if no valid year specification can be found.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
MonthMixin
|
|
|
|
~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: MonthMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin that can be used to retrieve and provide parsing information for a
|
|
|
|
month component of a date.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: month_format
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
The :func:`~time.strftime` format to use when parsing the month. By default, this is
|
2010-10-19 05:39:30 +08:00
|
|
|
``'%b'``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: month
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Optional** The value for the month (as a string). By default, set to
|
|
|
|
``None``, which means the month will be determined using other means.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_month_format()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
Returns the :func:`~time.strftime` format to use when parsing the month. Returns
|
2010-10-19 05:39:30 +08:00
|
|
|
:attr:`MonthMixin.month_format` by default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_month()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the month for which this view will display data. Tries the
|
|
|
|
following sources, in order:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* The value of the :attr:`MonthMixin.month` attribute.
|
|
|
|
* The value of the `month` argument captured in the URL pattern
|
|
|
|
* The value of the `month` GET query argument.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Raises a 404 if no valid month specification can be found.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_next_month(date)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a date object containing the first day of the month after the
|
2010-11-26 10:56:58 +08:00
|
|
|
date provided. Returns ``None`` if mixed with a view that sets
|
2010-10-19 05:39:30 +08:00
|
|
|
``allow_future = False``, and the next month is in the future. If
|
|
|
|
``allow_empty = False``, returns the next month that contains data.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_prev_month(date)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a date object containing the first day of the month before the
|
|
|
|
date provided. If ``allow_empty = False``, returns the previous month
|
|
|
|
that contained data.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
DayMixin
|
|
|
|
~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: DayMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin that can be used to retrieve and provide parsing information for a
|
|
|
|
day component of a date.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: day_format
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
The :func:`~time.strftime` format to use when parsing the day. By default, this is
|
2010-10-19 05:39:30 +08:00
|
|
|
``'%d'``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: day
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Optional** The value for the day (as a string). By default, set to
|
|
|
|
``None``, which means the day will be determined using other means.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_day_format()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
Returns the :func:`~time.strftime` format to use when parsing the day. Returns
|
2010-10-19 05:39:30 +08:00
|
|
|
:attr:`DayMixin.day_format` by default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_day()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the day for which this view will display data. Tries the
|
|
|
|
following sources, in order:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* The value of the :attr:`DayMixin.day` attribute.
|
|
|
|
* The value of the `day` argument captured in the URL pattern
|
|
|
|
* The value of the `day` GET query argument.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Raises a 404 if no valid day specification can be found.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_next_day(date)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a date object containing the next day after the date provided.
|
2010-11-26 10:56:58 +08:00
|
|
|
Returns ``None`` if mixed with a view that sets ``allow_future = False``,
|
2010-10-19 05:39:30 +08:00
|
|
|
and the next day is in the future. If ``allow_empty = False``, returns
|
|
|
|
the next day that contains data.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_prev_day(date)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a date object containing the previous day. If
|
|
|
|
``allow_empty = False``, returns the previous day that contained data.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
WeekMixin
|
|
|
|
~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: WeekMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin that can be used to retrieve and provide parsing information for a
|
|
|
|
week component of a date.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: week_format
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
The :func:`~time.strftime` format to use when parsing the week. By default, this is
|
2010-10-19 05:39:30 +08:00
|
|
|
``'%U'``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: week
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Optional** The value for the week (as a string). By default, set to
|
|
|
|
``None``, which means the week will be determined using other means.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_week_format()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-09-05 05:17:30 +08:00
|
|
|
Returns the :func:`~time.strftime` format to use when parsing the week. Returns
|
2010-10-19 05:39:30 +08:00
|
|
|
:attr:`WeekMixin.week_format` by default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_week()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the week for which this view will display data. Tries the
|
|
|
|
following sources, in order:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* The value of the :attr:`WeekMixin.week` attribute.
|
|
|
|
* The value of the `week` argument captured in the URL pattern
|
|
|
|
* The value of the `week` GET query argument.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Raises a 404 if no valid week specification can be found.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
DateMixin
|
|
|
|
~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: DateMixin()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A mixin class providing common behavior for all date-based views.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: date_field
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The name of the ``DateField`` or ``DateTimeField`` in the
|
|
|
|
``QuerySet``'s model that the date-based archive should use to
|
|
|
|
determine the objects on the page.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: allow_future
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A boolean specifying whether to include "future" objects on this page,
|
|
|
|
where "future" means objects in which the field specified in
|
|
|
|
``date_field`` is greater than the current date/time. By default, this
|
|
|
|
is ``False``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_date_field()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the name of the field that contains the date data that this
|
|
|
|
view will operate on. Returns :attr:`DateMixin.date_field` by default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_allow_future()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Determine whether to include "future" objects on this page, where
|
|
|
|
"future" means objects in which the field specified in ``date_field``
|
|
|
|
is greater than the current date/time. Returns
|
2011-08-22 10:03:50 +08:00
|
|
|
:attr:`DateMixin.allow_future` by default.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
BaseDateListView
|
|
|
|
~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseDateListView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A base class that provides common behavior for all date-based views. There
|
|
|
|
won't normally be a reason to instantiate
|
|
|
|
:class:`~django.views.generic.dates.BaseDateListView`; instantiate one of
|
|
|
|
the subclasses instead.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
While this view (and it's subclasses) are executing, ``self.object_list``
|
|
|
|
will contain the list of objects that the view is operating upon, and
|
|
|
|
``self.date_list`` will contain the list of dates for which data is
|
|
|
|
available.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`~django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`~django.views.generic.list.MultipleObjectMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: allow_empty
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A boolean specifying whether to display the page if no objects are
|
2011-07-29 17:40:35 +08:00
|
|
|
available. If this is ``True`` and no objects are available, the view
|
|
|
|
will display an empty page instead of raising a 404. By default, this
|
|
|
|
is ``False``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_dated_items():
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2012-02-19 05:40:00 +08:00
|
|
|
Returns a 3-tuple containing (``date_list``, ``object_list``,
|
2010-10-19 05:39:30 +08:00
|
|
|
``extra_context``).
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
``date_list`` is the list of dates for which data is available.
|
2012-02-19 05:40:00 +08:00
|
|
|
``object_list`` is the list of objects. ``extra_context`` is a
|
2010-10-19 05:39:30 +08:00
|
|
|
dictionary of context data that will be added to any context data
|
|
|
|
provided by the
|
2010-11-21 04:40:16 +08:00
|
|
|
:class:`~django.views.generic.list.MultipleObjectMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_dated_queryset(**lookup)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns a queryset, filtered using the query arguments defined by
|
|
|
|
``lookup``. Enforces any restrictions on the queryset, such as
|
|
|
|
``allow_empty`` and ``allow_future``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_date_list(queryset, date_type)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Returns the list of dates of type ``date_type`` for which
|
|
|
|
``queryset`` contains entries. For example, ``get_date_list(qs,
|
|
|
|
'year')`` will return the list of years for which ``qs`` has entries.
|
2011-09-30 18:28:39 +08:00
|
|
|
See :meth:`~django.db.models.query.QuerySet.dates()` for the
|
2010-10-19 05:39:30 +08:00
|
|
|
ways that the ``date_type`` argument can be used.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
Generic views
|
|
|
|
=============
|
|
|
|
|
|
|
|
Simple generic views
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.base
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
View
|
|
|
|
~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: View()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The master class-based base view. All other generic class-based views
|
|
|
|
inherit from this base class.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Each request served by a :class:`~django.views.generic.base.View` has an
|
|
|
|
independent state; therefore, it is safe to store state variables on the
|
|
|
|
instance (i.e., ``self.foo = 3`` is a thread-safe operation).
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A class-based view is deployed into a URL pattern using the
|
|
|
|
:meth:`~View.as_view()` classmethod::
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
urlpatterns = patterns('',
|
|
|
|
(r'^view/$', MyView.as_view(size=42)),
|
|
|
|
)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Any argument passed into :meth:`~View.as_view()` will be assigned onto the
|
|
|
|
instance that is used to service a request. Using the previous example,
|
|
|
|
this means that every request on ``MyView`` is able to interrogate
|
|
|
|
``self.size``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. admonition:: Thread safety with view arguments
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Arguments passed to a view are shared between every instance of a view.
|
|
|
|
This means that you shoudn't use a list, dictionary, or any other
|
|
|
|
variable object as an argument to a view. If you did, the actions of
|
|
|
|
one user visiting your view could have an effect on subsequent users
|
|
|
|
visiting the same view.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: dispatch(request, *args, **kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The ``view`` part of the view -- the method that accepts a ``request``
|
|
|
|
argument plus arguments, and returns a HTTP response.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The default implementation will inspect the HTTP method and attempt to
|
|
|
|
delegate to a method that matches the HTTP method; a ``GET`` will be
|
|
|
|
delegated to :meth:`~View.get()`, a ``POST`` to :meth:`~View.post()`,
|
|
|
|
and so on.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The default implementation also sets ``request``, ``args`` and
|
|
|
|
``kwargs`` as instance variables, so any method on the view can know
|
|
|
|
the full details of the request that was made to invoke the view.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: http_method_not_allowed(request, *args, **kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
If the view was called with HTTP method it doesn't support, this method
|
|
|
|
is called instead.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The default implementation returns ``HttpResponseNotAllowed`` with list
|
|
|
|
of allowed methods in plain text.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
TemplateView
|
|
|
|
~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: TemplateView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Renders a given template, passing it a ``{{ params }}`` template variable,
|
|
|
|
which is a dictionary of the parameters captured in the URL.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.base.TemplateResponseMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: template_name
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The full name of a template to use.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_context_data(**kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Return a context data dictionary consisting of the contents of
|
|
|
|
``kwargs`` stored in the context variable ``params``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``params``: The dictionary of keyword arguments captured from the URL
|
|
|
|
pattern that served the view.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
RedirectView
|
|
|
|
~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: RedirectView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Redirects to a given URL.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The given URL may contain dictionary-style string formatting, which will be
|
|
|
|
interpolated against the parameters captured in the URL. Because keyword
|
|
|
|
interpolation is *always* done (even if no arguments are passed in), any
|
|
|
|
``"%"`` characters in the URL must be written as ``"%%"`` so that Python
|
|
|
|
will convert them to a single percent sign on output.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
If the given URL is ``None``, Django will return an ``HttpResponseGone``
|
|
|
|
(410).
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: url
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The URL to redirect to, as a string. Or ``None`` to raise a 410 (Gone)
|
|
|
|
HTTP error.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: permanent
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Whether the redirect should be permanent. The only difference here is
|
|
|
|
the HTTP status code returned. If ``True``, then the redirect will use
|
|
|
|
status code 301. If ``False``, then the redirect will use status code
|
|
|
|
302. By default, ``permanent`` is ``True``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: query_string
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Whether to pass along the GET query string to the new location. If
|
|
|
|
``True``, then the query string is appended to the URL. If ``False``,
|
|
|
|
then the query string is discarded. By default, ``query_string`` is
|
|
|
|
``False``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_redirect_url(**kwargs)
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Constructs the target URL for redirection.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
The default implementation uses :attr:`~RedirectView.url` as a starting
|
|
|
|
string, performs expansion of ``%`` parameters in that string, as well
|
|
|
|
as the appending of query string if requested by
|
|
|
|
:attr:`~RedirectView.query_string`. Subclasses may implement any
|
|
|
|
behavior they wish, as long as the method returns a redirect-ready URL
|
|
|
|
string.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
Detail views
|
|
|
|
------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.detail
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
DetailView
|
|
|
|
~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseDetailView()
|
|
|
|
.. class:: DetailView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A page representing an individual object.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
While this view is executing, ``self.object`` will contain the object that
|
|
|
|
the view is operating upon.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.base.BaseDetailView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.base.DetailView`, but doesn't
|
|
|
|
include the
|
|
|
|
:class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.detail.SingleObjectMixin`
|
|
|
|
* :class:`django.views.generic.detail.SingleObjectTemplateResponseMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
List views
|
|
|
|
----------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.list
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
ListView
|
|
|
|
~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseListView()
|
|
|
|
.. class:: ListView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A page representing a list of objects.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.list.BaseListView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.list.ListView`, but doesn't
|
|
|
|
include the
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.list.MultipleObjectMixin`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
Editing views
|
|
|
|
-------------
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.edit
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
FormView
|
|
|
|
~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseFormView()
|
|
|
|
.. class:: FormView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A view that displays a form. On error, redisplays the form with validation
|
|
|
|
errors; on success, redirects to a new URL.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.edit.BaseFormView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.edit.FormView`, but doesn't
|
|
|
|
include the :class:`~django.views.generic.base.TemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.edit.FormMixin`
|
|
|
|
* :class:`django.views.generic.edit.ProcessFormView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
CreateView
|
|
|
|
~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseCreateView()
|
|
|
|
.. class:: CreateView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A view that displays a form for creating an object, redisplaying the form
|
|
|
|
with validation errors (if there are any) and saving the object.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.edit.BaseCreateView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.edit.CreateView`, but doesn't
|
|
|
|
include the :class:`~django.views.generic.base.TemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.edit.ModelFormMixin`
|
|
|
|
* :class:`django.views.generic.edit.ProcessFormView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
UpdateView
|
|
|
|
~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseUpdateView()
|
|
|
|
.. class:: UpdateView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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).
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.edit.BaseUpdateView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.edit.UpdateView`, but doesn't
|
|
|
|
include the :class:`~django.views.generic.base.TemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.edit.ModelFormMixin`
|
|
|
|
* :class:`django.views.generic.edit.ProcessFormView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
DeleteView
|
|
|
|
~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseDeleteView()
|
|
|
|
.. class:: DeleteView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.edit.BaseDeleteView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.edit.DeleteView`, but doesn't
|
|
|
|
include the :class:`~django.views.generic.base.TemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.edit.DeletionMixin`
|
|
|
|
* :class:`django.views.generic.detail.BaseDetailView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Notes**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* The delete confirmation page displayed to a GET request uses a
|
|
|
|
``template_name_suffix`` of ``'_confirm_delete'``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
|
|
|
Date-based views
|
|
|
|
----------------
|
|
|
|
|
|
|
|
Date-based generic views (in the module :mod:`django.views.generic.dates`)
|
|
|
|
are views for displaying drilldown pages for date-based data.
|
|
|
|
|
|
|
|
.. currentmodule:: django.views.generic.dates
|
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
ArchiveIndexView
|
|
|
|
~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseArchiveIndexView()
|
|
|
|
.. class:: ArchiveIndexView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.dates.BaseArchiveIndexView` implements the
|
|
|
|
same behavior as :class:`~django.views.generic.dates.ArchiveIndexView`, but
|
|
|
|
doesn't include the
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Notes**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Uses a default ``context_object_name`` of ``latest``.
|
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
YearArchiveView
|
|
|
|
~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseYearArchiveView()
|
|
|
|
.. class:: YearArchiveView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.dates.BaseYearArchiveView` implements the
|
|
|
|
same behavior as :class:`~django.views.generic.dates.YearArchiveView`, but
|
|
|
|
doesn't include the
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. attribute:: make_object_list
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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. By default, this is
|
|
|
|
``False``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
.. method:: get_make_object_list()
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
Determine if an object list will be returned as part of the context. If
|
|
|
|
``False``, the ``None`` queryset will be used as the object list.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
In addition to the context provided by
|
|
|
|
:class:`django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``date_list``: A ``DateQuerySet`` object containing all months that
|
|
|
|
have objects available according to ``queryset``, represented as
|
|
|
|
``datetime.datetime`` objects, in ascending order.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``year``: The given year, as a four-character string.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Notes**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_year``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
MonthArchiveView
|
|
|
|
~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseMonthArchiveView()
|
|
|
|
.. class:: MonthArchiveView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.dates.BaseMonthArchiveView` implements
|
|
|
|
the same behavior as
|
|
|
|
:class:`~django.views.generic.dates.MonthArchiveView`, but doesn't
|
|
|
|
include the
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
In addition to the context provided by
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`~django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``date_list``: A ``DateQuerySet`` object containing all days that
|
|
|
|
have objects available in the given month, according to ``queryset``,
|
|
|
|
represented as ``datetime.datetime`` objects, in ascending order.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``month``: A ``datetime.date`` object representing the given month.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``next_month``: A ``datetime.date`` object representing the first day
|
|
|
|
of the next month. If the next month is in the future, this will be
|
|
|
|
``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``previous_month``: A ``datetime.date`` object representing the first
|
|
|
|
day of the previous month. Unlike ``next_month``, this will never be
|
|
|
|
``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Notes**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_month``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
WeekArchiveView
|
|
|
|
~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseWeekArchiveView()
|
|
|
|
.. class:: WeekArchiveView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
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``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.dates.BaseWeekArchiveView` implements the
|
|
|
|
same behavior as :class:`~django.views.generic.dates.WeekArchiveView`, but
|
|
|
|
doesn't include the
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
In addition to the context provided by
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`~django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``week``: A ``datetime.date`` object representing the first day of
|
|
|
|
the given week.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Notes**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_week``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
DayArchiveView
|
|
|
|
~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseDayArchiveView()
|
|
|
|
.. class:: DayArchiveView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A day archive page showing all objects in a given day. Days in the future
|
|
|
|
throw a 404 error, regardless of whether any objects exist for future days,
|
|
|
|
unless you set ``allow_future`` to ``True``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.dates.BaseDayArchiveView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.dates.DayArchiveView`, but
|
|
|
|
doesn't include the
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.DayMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDateListView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Context**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
In addition to the context provided by
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectMixin` (via
|
|
|
|
:class:`~django.views.generic.dates.BaseDateListView`), the template's
|
|
|
|
context will be:
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``day``: A ``datetime.date`` object representing the given day.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``next_day``: A ``datetime.date`` object representing the next day.
|
|
|
|
If the next day is in the future, this will be ``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``previous_day``: A ``datetime.date`` object representing the
|
|
|
|
previous day. Unlike ``next_day``, this will never be ``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``next_month``: A ``datetime.date`` object representing the first day
|
|
|
|
of the next month. If the next month is in the future, this will be
|
|
|
|
``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* ``previous_month``: A ``datetime.date`` object representing the first
|
|
|
|
day of the previous month. Unlike ``next_month``, this will never be
|
|
|
|
``None``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Notes**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* Uses a default ``template_name_suffix`` of ``_archive_day``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
TodayArchiveView
|
|
|
|
~~~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseTodayArchiveView()
|
|
|
|
.. class:: TodayArchiveView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A day archive page showing all objects for *today*. This is exactly the
|
2011-07-29 17:40:15 +08:00
|
|
|
same as :class:`django.views.generic.dates.DayArchiveView`, except today's
|
|
|
|
date is used instead of the ``year``/``month``/``day`` arguments.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.dates.BaseTodayArchiveView` implements the
|
|
|
|
same behavior as :class:`~django.views.generic.dates.TodayArchiveView`, but
|
|
|
|
doesn't include the
|
|
|
|
:class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.dates.BaseDayArchiveView`
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 07:09:13 +08:00
|
|
|
DateDetailView
|
|
|
|
~~~~~~~~~~~~~~
|
2010-10-18 21:34:47 +08:00
|
|
|
.. class:: BaseDateDetailView()
|
|
|
|
.. class:: DateDetailView()
|
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
A page representing an individual object. If the object has a date value in
|
|
|
|
the future, the view will throw a 404 error by default, unless you set
|
|
|
|
``allow_future`` to ``True``.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
:class:`~django.views.generic.dates.BaseDateDetailView` implements the same
|
|
|
|
behavior as :class:`~django.views.generic.dates.DateDetailView`, but
|
|
|
|
doesn't include the
|
|
|
|
:class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2010-10-19 05:39:30 +08:00
|
|
|
**Mixins**
|
2010-10-18 21:34:47 +08:00
|
|
|
|
2011-10-14 08:12:01 +08:00
|
|
|
* :class:`django.views.generic.detail.SingleObjectTemplateResponseMixin`
|
|
|
|
* :class:`django.views.generic.detail.BaseDetailView`
|
|
|
|
* :class:`django.views.generic.dates.DateMixin`
|
|
|
|
* :class:`django.views.generic.dates.YearMixin`
|
|
|
|
* :class:`django.views.generic.dates.MonthMixin`
|
|
|
|
* :class:`django.views.generic.dates.DayMixin`
|