.. ========================= Class-based generic views ========================= ====================== クラスベース汎用ビュー ====================== :revision-up-to: 17812 (1.4) .. 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. For details on the previous generic views implementation, see the :doc:`topic guide ` and :doc:`detailed reference `. .. note:: Django 1.3 の前は、汎用ビューは関数として実装されていました。ここで述べる クラスベース汎用ビューが採用されたので、関数ベース汎用ビューは廃止されま した。 関数ベース汎用ビューの詳細は :doc:`トピックガイド ` と :doc:`詳細リファレンス ` を参照してください。 .. Writing Web applications can be monotonous, because we repeat certain patterns 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. Web アプリケーションの作成は、同じパターンを何度も何度も繰り返し書くことに なるため、退屈なものです。 Django は、こうした単調作業をモデルやテンプレー トのレイヤで軽減しようとしていますが、 Web 開発者はビューレベルでも退屈さを 感じています。 .. A general introduction to class-based generic views can be found in the :doc:`topic guide `. クラスベース汎用ビューの概略は :doc:`トピックガイド ` を参照してください。 .. This reference contains details of Django's built-in generic views, along with a list of the keyword arguments that each generic view expects. Remember that arguments may either come from the URL pattern or from the ``extra_context`` additional-information dictionary. このリファレンスでは Django 組み込みの汎用ビューの詳細を記述しています。 それぞれのビューが期待するキーワード引数についても記述しています。 それらの引数は URL パターンか、付加情報である ``extra_context`` 辞書のどちらかから得られると 覚えておいてください。 .. Most generic views require the ``queryset`` key, which is a ``QuerySet`` instance; see :doc:`/topics/db/queries` for more information about ``QuerySet`` objects. 多くの汎用ビューは ``QuerySet`` のインスタンスである ``queryset`` キーを要求します。 ``QuerySet`` オブジェクトについては :doc:`/topics/db/queries` を参照してください。 .. Mixins ====== Mixin ===== .. 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 class-based generic views are constructed by composing mixins into usable generic views. Mixin クラスは、クラスの機能継承のために使われます。小分けにした振る舞い (behavior) からクラスを構成します。 Django のクラスベース汎用ビューは、適切な汎用ビューに Mixin を組み合わせて構築します。 .. For example, the :class:`~django.views.generic.base.detail.DetailView` is composed from: 例えば :class:`~django.views.generic.base.detail.DetailView` を構成しているのは 以下になります。 .. * :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. * :class:`~django.db.views.generic.base.View` 、クラスベースの振る舞いを決める 基本を提供します。 * :class:`~django.db.views.generic.detail.SingleObjectMixin` 、単一のオブジェクトを 取得して表示するユーティリティを提供します。 * :class:`~django.db.views.generic.detail.SingleObjectTemplateResponseMixin` 、 単一のオブジェクトを、テンプレートベースのレスポンスで表現するためのツールを提供します。 .. 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. 組み合せることにより、以上の Mixin が目的のビューに必要な要素をすべて提供します。 このビューが返すレスポンスは、単一オブジェクトによりテンプレートをレンダリングしたものです。 .. 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. Django はたくさんの Mixin を提供しています。自分での汎用ビューを作りたいときは、 それら Mixin を面白い方法で組み合わせてクラスを作りましょう。もしくは Django が提供する、すでにミックスされた (pre-mixied) `汎用ビュー`_ を使うだけでも 良いでしょう。 .. .. note:: When the documentation for a view gives the list of mixins, that view inherits all the properties and methods of that mixin. .. note:: ビューのドキュメントに Mixin のリストが書かれているときは、そのビューが Mixin から全てのプロパティ、メソッドを受け継いでいるということです。 .. Simple mixins ------------- 単純な Mixin ------------ .. currentmodule:: django.views.generic.base .. TemplateResponseMixin ~~~~~~~~~~~~~~~~~~~~~ TemplateResponseMixin ~~~~~~~~~~~~~~~~~~~~~ .. class:: TemplateResponseMixin() .. attribute:: template_name .. The path to the template to use when rendering the view. 対象ビューのレンダリングに使われるテンプレートのパスになります。 .. attribute:: response_class .. The response class to be returned by ``render_to_response`` method. Default is :class:`TemplateResponse `. The template and context of ``TemplateResponse`` instances can be altered later (e.g. in :ref:`template response middleware `). これはレスポンス用のクラスで ``render_to_response`` メソッドにより返されます。 デフォルトは :class:`TemplateResponse ` です。 ``TemplateResponse`` インスタンスのテンプレートとコンテキストについては 後の :class:`TemplateResponse ` で後述します。 .. If you need custom template loading or custom context object instantiation, create a ``TemplateResponse`` subclass and assign it to ``response_class``. もしテンプレートの読み込みやコンテキストオブジェクトをカスタムしたい なら、 ``TemplateResponse`` をサブプラス化して、それを ``response_class`` に指定してください。 .. method:: render_to_response(context, **response_kwargs) .. Returns a ``self.response_class`` instance. ``self.response_class`` のインスタンスを返します。 .. If any keyword arguments are provided, they will be passed to the constructor of the response class. キーワード引数が 1 つも与えられない場合は、レスポンスクラスのコンストラクタ を返します。 .. Calls :meth:`~TemplateResponseMixin.get_template_names()` to obtain the list of template names that will be searched looking for an existent template. テンプレートを見つけるために :meth:`~TemplateResponseMixin.get_template_names()` が呼び出されます。 これによってテンプレート名のリストが取得されます。 .. method:: get_template_names() .. Returns a list of template names to search for when rendering the template. テンプレート名のリストを返します。テンプレートレンダリング時の検索に 使われます。 .. If :attr:`TemplateResponseMixin.template_name` is specified, the default implementation will return a list containing :attr:`TemplateResponseMixin.template_name` (if it is specified). :attr:`TemplateResponseMixin.template_name` が指定されている場合、 デフォルトのままでは :attr:`TemplateResponseMixin.template_name` を含むリストが返されます。 (それが指定されている場合は) .. Single object mixins -------------------- 単一オブジェクトの Mixin ------------------------ .. currentmodule:: django.views.generic.detail .. SingleObjectMixin ~~~~~~~~~~~~~~~~~ SingleObjectMixin ~~~~~~~~~~~~~~~~~ .. class:: SingleObjectMixin() .. attribute:: model .. The model that this view will display data for. Specifying ``model = Foo`` is effectively the same as specifying ``queryset = Foo.objects.all()``. ビューがデータを表示するモデルです。 ``model = Foo`` と指定すると、 ``queryset = Foo.objects.all()`` と同じ意味になります。 .. attribute:: queryset .. A ``QuerySet`` that represents the objects. If provided, the value of :attr:`SingleObjectMixin.queryset` supersedes the value provided for :attr:`SingleObjectMixin.model`. ``QuerySet`` はオブジェクトを表現します。与えられた場合は :attr:`SingleObjectMixin.queryset` の値が :attr:`SingleObjectMixin.model` に与えられた値に置き換わります。 .. attribute:: slug_field .. The name of the field on the model that contains the slug. By default, ``slug_field`` is ``'slug'``. スラグ (:term:`slug`) を含むモデルのフィールド名になります。デフォルト で ``slug_field`` は ``'slug'`` です。 .. 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'``. URLConf キーワード引数からのスラグ名です。デフォルトで ``slug_url_kwarg`` は ``'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'``. URLConf キーワード引数からプライマリキー名です。デフォルトで ``pk_url_kwarg`` は ``'pk'`` です。 .. attribute:: context_object_name .. Designates the name of the variable to use in the context. コンテキストで使う変数名を指定します。 .. 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. ``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` argument, and performs a slug lookup using the :attr:`SingleObjectMixin.slug_field`. ビューで表示される単一のオブジェクトを返します。 ``queryset`` が 与えられた場合は、このクエリセットからオブジェクトが取得されます。 そうでなければ :meth:`~SingleObjectMixin.get_queryset` が使われます。 ``get_object()`` は :attr:`SingleObjectMixin.pk_url_kwarg` 引数を ビューへの引数から探します。もし見つかった場合は、メソッドはプライマリ キーの値を使って探します。見つからない場合は、 :attr:`SingleObjectMixin.slug_url_kwarg` 引数が探され、 :attr:`SingleObjectMixin.slug_field` からスラグを探します。 .. method:: get_queryset() .. 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. クエリセットを返します。このクエリセットからオブジェクトが取得され、 ビューにより表示されます。デフォルトで :meth:`~SingleObjectMixin.get_queryset` は :attr:`~SingleObjectMixin.queryset` が設定されていると、これを返します。 そうでない場合、 :attr:`~SingleObjectMixin.model` 引数のデフォルト マネジャから `all()` メソッドを呼び出して :class:`QuerySet` を生成 します。 .. method:: get_context_object_name(obj) .. Return the context variable name that will be used to contain the data that this view is manipulating. If :attr:`~SingleObjectMixin.context_object_name` is not set, the context 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'``. このビューが扱うデータを含む、コンテキストの変数名を返します。 :attr:`~SingleObjectMixin.context_object_name` が設定されていない場合、 コンテキスト名はクエリセットを構成するモデルの ``object_name`` から 生成されます。例えば ``Article`` モデルの場合は ``article`` という名の コンテキストオブジェクトになります。 .. method:: get_context_data(**kwargs) .. Returns context data for displaying the list of objects. オブジェクトのリストを表示するための、コンテキストデータを返します。 .. **Context** **コンテキスト** .. * ``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``. * ``object``: このビューが表示するオブジェクトです。 ``context_object_name`` が指定させれている場合、この変数はコンテキストに ``object`` と同じ値で設定されます。 .. SingleObjectTemplateResponseMixin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SingleObjectTemplateResponseMixin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. class:: 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. テンプレートベースのレスポンスをレンダリングする Mixin クラスです。単一 のオブジェクトインスタンスを扱うビューに使われます。ミックスされたビューは ``self.object`` の提供が必要になります。このオブジェクトインスタンスは ビューが扱うものです。 ``self.object`` はいつも Django のモデルになるでし ょう。しかし必須ではなく、 ``None`` のこともあります。ビューが新しい インスタンスを構成している段階ではそうなります。 .. **Extends** **拡張点** * :class:`~django.views.generic.base.TemplateResponseMixin` .. attribute:: 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`` 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. 現在のオブジェクトインスタンスのフィールド名で、候補になるテンプレート名 を特定するために使われます。 ``template_name_field`` か、現在の オブジェクトインスタンスの ``template_name_field`` の値が ``None`` の 場合は、オブジェクトはテンプレート名の特定に問い合わされることはなく なります。 .. attribute:: template_name_suffix .. The suffix to append to the auto-generated candidate template name. Default suffix is ``_detail``. 自動生成されるテンプレート名の候補のために追加されるサフィックスになり ます。デフォルトのサフィックスは ``_detail`` です。 .. method:: 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) * ``/.html`` テンプレート名の候補をリストで返します。以下のようなリストを返します: * ビューの ``template_name`` の値 (与えられている場合) * オブジェクトインスタンスの ``template_name_field`` フィールドの値。 このオブジェクトインスタンスはビューが扱っているものです。 (取得できる 場合) * ``/.html`` .. Multiple object mixins ---------------------- 複数オブジェクトの Mixin ------------------------ .. currentmodule:: django.views.generic.list .. MultipleObjectMixin ~~~~~~~~~~~~~~~~~~~ MultipleObjectMixin ~~~~~~~~~~~~~~~~~~~ .. class:: MultipleObjectMixin() .. A mixin that can be used to display a list of objects. オブジェクトのリストを表示するために使われる Mixin です。 .. 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: ``paginate_by`` が指定されている場合、 Django はこれに返される結果をページ 分割 (paginate) します。 URL からページ番号を特定するには 2 つの方法が あります。 .. * Use the ``page`` parameter in the URLconf. For example, this is what your URLconf might look like:: (r'^objects/page(?P[0-9]+)/$', PaginatedView.as_view()) * URLConf で ``page`` パラメータを使います。例えば URLConf はこのように なります:: (r'^objects/page(?P[0-9]+)/$', PaginatedView.as_view()) .. * Pass the page number via the ``page`` query-string parameter. For example, a URL would look like this:: /objects/?page=3 * ページ番号を ``page`` クエリ文字列パラメータで渡します。例えば URL Conf はこのようになります:: /objects/?page=3 .. These values and lists are 1-based, not 0-based, so the first page would be represented as page ``1``. これらの値とリストは 1 オリジンであり、 0 オリジンではありません。最初の ページは ``1`` で表されます。 .. For more on pagination, read the :doc:`pagination documentation `. ページ分割 (pagination) に関する詳細は、 :doc:`ページ分割のドキュメント ` を読んでください。 .. As a special case, you are also permitted to use ``last`` as a value for ``page``:: /objects/?page=last 特殊なケースとして、 ``page`` には ``last`` という値も認められています:: /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. ``page`` は *必ず* ページ番号か ``last`` でなけれならないことに注意して ください。 ``page`` がその他の値の場合は 404 エラーが返されます。 .. attribute:: 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``. 利用できるオブジェクトがない場合にページを表示するかどうかをブール値に よって指定します。これが ``False`` で、利用できるオブジェクトがない場合、 空白のページを表示する代わりに、ビューは 404 を送出します。デフォルト では ``True`` です。 .. attribute:: model .. The model that this view will display data for. Specifying ``model = Foo`` is effectively the same as specifying ``queryset = Foo.objects.all()``. ビューがデータを表示するためのモデルになります。 ``model=Foo`` と指定 することは、 ``queryset = Foo.objects.all()`` と同じ意味になります。 .. attribute:: queryset .. A ``QuerySet`` that represents the objects. If provided, the value of :attr:`MultipleObjectMixin.queryset` supersedes the value provided for :attr:`MultipleObjectMixin.model`. オブジェクトを表す ``QuerySet`` になります。与えられた場合、 :attr:`MultipleObjectMixin.queryset` は :attr:`MultipleObjectMixin.model` で与えられた値を置き換えます。 .. attribute:: paginate_by .. 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. 1 ページあたりのオブジェクトの表示数を指定する整数になります。与えられた 場合、ビューは 1 ページあたり :attr:`MultipleObjectMixin.paginate_by` オブジェクトでオブジェクトをページ分割します。ビューは (``GET`` からの) ``page`` クエリ文字列パラメータか、 URLConf で指定される ``page`` 変数 に期待します。 .. 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`. ページネータクラスはページ分割に使われます。デフォルトでは :class:`django.core.paginator.Paginator` が使われます。カスタムの ページネータが、 :class:`django.core.paginator.Paginator` と同じ コンストラクタインタフェースを持っていない場合は、 :meth:`MultipleObjectMixin.get_paginator` も提供する必要があります。 .. attribute:: context_object_name .. Designates the name of the variable to use in the context. コンテクストで使われる変数名を指定します。 .. method:: get_queryset() .. Returns the queryset that represents the data this view will display. ビューが表示するデータを表すクエリセットを返します。 .. method:: paginate_queryset(queryset, page_size) .. Returns a 4-tuple containing (``paginator``, ``page``, ``object_list``, ``is_paginated``). 4 要素のタプル (``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. 1 ページあたりのサイズ ``page_size`` で、 ``queryset`` をページ分割する よう構成します。リクエストが ``page`` 引数を含んでいる場合や、 URL 引数、 GET 引数として取得できた場合は、 ``object_list`` は、そのページにある べきオブジェクトになります。 .. method:: get_paginate_by(queryset) .. 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`. ページ分割される際のアイテム数を返します。ページ分割されない場合は ``None`` を返します。デフォルトでは単純に :attr:`MultipleObjectMixin.paginate_by` の値を返します。 .. method:: 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 :attr:`paginator_class`. ビューで使用されるページネータのインスタンスを返します。デフォルトでは :attr:`paginator_class` のインスタンスになります。 .. method:: 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``. 利用できるオブジェクトがない場合にページを表示するかどうかを指定する ブール値を返します。このメソッドが ``False`` を返して、オブジェクトが 利用できない場合、空白のページを表示する代わりに、ビューは 404 を送出 します。デフォルトでは ``True`` です。 .. method:: 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 :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``. ビューが扱うデータのリストを含むコンテキスト変数の名前を返します。 ``object_list`` が Django オブジェクトのクエリセットで、 :attr:`~MultipleObjectMixin.context_object_name` が設定されていない 場合、コンテキスト名にはクエリセットに含まれるモデルの ``object_name`` に ``'list'`` サフィックスを追加したものが使われます。モデル ``Article`` はコンテキストオブジェクト名 ``article_list`` を持ちます。 .. method:: 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``. * ``object_list``: ビューが表示させるオブジェクトのリストです。 ``context_object_name`` が指定されている場合、この変数の値でもコンテキスト に設定されます。値は ``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. * ``is_paginated``: 結果がページ分割されるかどうかを表現するブール値になり ます。とりわけ、これが ``False`` になるのは、ページサイズが指定されて いない場合と、取得したオブジェクトが複数ページに分割できない場合です。 .. * ``paginator``: An instance of :class:`django.core.paginator.Paginator`. If the page is not paginated, this context variable will be ``None``. * ``paginator``: :class:`django.core.paginator.Paginator` のインスタンスになり ます。ページが分割されていない場合、このコンテキスト変数は ``None`` になり ます。 .. * ``page_obj``: An instance of :class:`django.core.paginator.Page`. If the page is not paginated, this context variable will be ``None``. * ``page_obj``: :class:`django.core.paginator.Page` のインスタンスになり ます。ページが分割されていない場合、このコンテキスト変数は ``None`` になり ます。 .. MultipleObjectTemplateResponseMixin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MultipleObjectTemplateResponseMixin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. class:: MultipleObjectTemplateResponseMixin() .. 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 to be, a :class:`~django.db.models.query.QuerySet`. ビューが扱うオブジェクトのリストを、テンプレートベースのレスポンスにレンダリ ングするMixin クラスです。ミックスされるビューは ``self.object_list`` を提供 する必要があり、オブジェクトインスタンスのリストはビュー内で操作される必要が あります。 ``self.object_list`` は、必須ではありませんが、 :class:`~django.db.models.query.QuerySet` になります。 .. **Extends** **Extends** * :class:`~django.views.generic.base.TemplateResponseMixin` .. attribute:: template_name_suffix .. The suffix to append to the auto-generated candidate template name. Default suffix is ``_list``. このサフィックスは自動生成されるテンプレート名の候補に付与されます。 デフォルトのサフィックスは ``_list`` です。 .. method:: get_template_names() .. Returns a list of candidate template names. Returns the following list: テンプレート名の候補を返します。以下のようになります: .. * the value of ``template_name`` on the view (if provided) * ``/.html`` * ビューの ``template_name`` の値 (与えられている場合) * ``/.html`` .. Editing mixins -------------- 編集用 (Editing) Mixin ---------------------- .. currentmodule:: django.views.generic.edit .. FormMixin ~~~~~~~~~ FormMixin ~~~~~~~~~ .. class:: FormMixin() .. A mixin class that provides facilities for creating and displaying forms. フォームを作成、表示する機能を提供する Mixin クラスです。 .. attribute:: initial .. A dictionary containing initial data for the form. フォームの初期データを含む辞書です。 .. attribute:: form_class .. The form class to instantiate. インスタンス化するためのフォームクラスです。 .. attribute:: success_url .. The URL to redirect to when the form is successfully processed. フォームが正常に動作した後のリダイレクト先 URL です。 .. method:: get_initial() .. Retrieve initial data for the form. By default, returns a copy of :attr:`.initial`. フォームから初期データを取得します。デフォルトでは :attr:`.initial` の 結果を返します。 .. admonition:: Changed in 1.4 .. In Django 1.3, this method was returning the :attr:`initial` class variable itself. Django 1.3 では、このメソッドは :attr:`initial` クラス変数そのものを 返していました。 .. method:: get_form_class() .. Retrieve the form class to instantiate. By default :attr:`.form_class`. インスタンス化するためのフォームクラスを取得します。デフォルトでは :attr:`.form_class` です。 .. method:: get_form(form_class) .. Instantiate an instance of ``form_class`` using :meth:`.get_form_kwargs`. :meth:`.get_form_kwargs` を使って ``form_class`` のインスタンスを返し ます。 .. method:: get_form_kwargs() .. Build the keyword arguments required to instantiate the form. フォームをインスタンス化するために必要なキーワード引数を構築します。 .. 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. ``initial`` 引数には :meth:`.get_initial` が設定されます。リクエストが ``POST`` か ``PUT`` の場合は、リクエストデータ (``request.POST`` と ``request.FILES``) が提供されるでしょう。 .. method:: get_success_url() .. Determine the URL to redirect to when the form is successfully validated. Returns :attr:`.success_url` by default. フォームが正常に動作した後のリダイレクト先 URL を決定します。デフォルト では :attr:`.success_url` を返します。 .. method:: form_valid(form) .. Redirects to :meth:`.get_success_url`. :meth:`.get_success_url` へリダイレクトします。 .. method:: form_invalid(form) .. Renders a response, providing the invalid form as context. 無効な場合のフォームをコンテキストで提供し、レスポンスをレンダリング します。 .. method:: get_context_data(**kwargs) .. Populates a context containing the contents of ``kwargs``. ``kwargs`` の内容を含むコンテキストを返します。 **Context** .. * ``form``: The form instance that was generated for the view. * ``form``: ビュー用に生成されたフォームインスタンスです。 .. .. note:: Views mixing :class:`FormMixin` must provide an implementation of :meth:`.form_valid` and :meth:`.form_invalid`. .. note:: :class:`FormMixin` をミックスしたビューは :meth:`.form_valid` 、 :meth:`.form_invalid` の両機能を提供しなければなりません。 .. ModelFormMixin ~~~~~~~~~~~~~~ ModelFormMixin ~~~~~~~~~~~~~~ .. class:: ModelFormMixin() .. A form mixin that works on ModelForms, rather than a standalone form. ModelForms で動作する フォーム Mixin です。独立したフォームではありません。 .. Since this is a subclass of :class:`~django.views.generic.detail.SingleObjectMixin`, instances of this mixin have access to the :attr:`~SingleObjectMixin.model` and :attr:`~SingleObjectMixin.queryset` attributes, describing the type of object that the ModelForm is manipulating. The view also provides ``self.object``, the instance being manipulated. If the instance is being created, ``self.object`` will be ``None``. これは :class:`~django.views.generic.detail.SingleObjectMixin` のサブクラス ですので、この Mixin のインスタンスは :attr:`~SingleObjectMixin.model` と :attr:`~SingleObjectMixin.queryset` 引数にアクセスできます。これによって ModelForm が扱うオブジェクトの種類を記述できます。ビューは ``self.object`` も 提供します。 ``self.object`` によってインスタンスを扱います。インスタンスが 作られるときは、 ``self.object`` は ``None`` になります。 .. **Mixins** **Mixin** * :class:`django.views.generic.edit.FormMixin` * :class:`django.views.generic.detail.SingleObjectMixin` .. attribute:: success_url .. The URL to redirect to when the form is successfully processed. フォームが正常に動作した後のリダイレクト先 URL です。 .. ``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. ``success_url`` は辞書の文字列フォーマットを含みます。オブジェクトの フィールド引数に対して補間されます。例えば ``success_url="/polls/%(slug)s/"`` を使って、モデルの ``slug`` フィールドから構成した URL にリダイレクトできます。 .. method:: get_form_class() .. 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 with the :attr:`~SingleObjectMixin.queryset`, or with the :attr:`~SingleObjectMixin.model`, depending on which attribute is provided. インスタンス化のためのフォームクラスを取得します。 :attr:`FormMixin.form_class` が与えられている場合、そのクラスが使われます。 そうでなければ ModelForm がインスタンス化されます。使われるモデルは :attr:`~SingleObjectMixin.queryset` か :attr:`~SingleObjectMixin.model` から予想されます。この場合どちらかの属性が提供されている必要があります。 .. method:: get_form_kwargs() .. Add the current instance (``self.object``) to the standard :meth:`FormMixin.get_form_kwargs`. 現在のインスタンス (``self.object``) を標準の :meth:`FormMixin.get_form_kwargs` に追加します。 .. method:: get_success_url() .. 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. フォームが正当な場合にリダイレクトする URL を返します。 :attr:`FormMixin.success_url` が与えられた場合は、それを返します。 そうでなければオブジェクトの ``get_absolute_url()`` の使います。 .. method:: form_valid(form) .. Saves the form instance, sets the current object for the view, and redirects to :meth:`.get_success_url`. フォームインスタンスを記録します。ビューに現在のオブジェクトを設定し、 :meth:`.get_success_url` にリダイレクトします。 .. method:: form_invalid() .. Renders a response, providing the invalid form as context. 無効な場合のフォームをコンテキストとして提供し、レスポンスをレンダリング します。 .. ProcessFormView ~~~~~~~~~~~~~~~ ProcessFormView ~~~~~~~~~~~~~~~ .. class:: ProcessFormView() .. A mixin that provides basic HTTP GET and POST workflow. 基本的な GET 、 POST ワークフローを提供する Mixin です。 .. method:: get(request, *args, **kwargs) .. Constructs a form, then renders a response using a context that contains that form. フォームを構成します。後にこのフォームが含まれるコンテキストを元に レスポンスがレンダリングされます。 .. method:: post(request, *args, **kwargs) .. Constructs a form, checks the form for validity, and handles it accordingly. フォームを構成し、フォームの正当性を評価します。その結果に沿って処理を 行います。 .. The PUT action is also handled, as an analog of POST. PUT アクションはアナログの POST として扱われます。 .. DeletionMixin ~~~~~~~~~~~~~ DeletionMixin ~~~~~~~~~~~~~ .. class:: DeletionMixin() .. Enables handling of the ``DELETE`` http action. ``DELETE`` http アクションの扱いを有効にします。 .. attribute:: success_url .. The url to redirect to when the nominated object has been successfully deleted. 指定されたオブジェクトが削除された場合にリダイレクトされる URL です。 .. method:: get_success_url(obj) .. 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. 指定されたオブジェクトがすでに削除されていた場合にリダイレクトする URL を返します。デフォルトでは :attr:`~django.views.generic.edit.DeletionMixin.success_url` を返し ます。 .. Date-based mixins ----------------- 日付ベースの Mixin ------------------- .. currentmodule:: django.views.generic.dates .. YearMixin ~~~~~~~~~ YearMixin ~~~~~~~~~ .. class:: YearMixin() .. A mixin that can be used to retrieve and provide parsing information for a year component of a date. ある日付の、年 (year) 要素をパースした情報を取得、提供する Mixin です。 Mixin .. attribute:: year_format .. The :func:`~time.strftime` format to use when parsing the year. By default, this is ``'%Y'``. 年をパースする際に使われる :func:`~time.strftime` フォーマットです。 デフォルトでは ``'%Y'`` です。 .. attribute:: 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. **オプション** (文字列としての) 年の値です。デフォルトでは ``None`` が 設定されています。この場合、年は他の手段によって決定されます。 .. method:: get_year_format() .. Returns the :func:`~time.strftime` format to use when parsing the year. Returns :attr:`YearMixin.year_format` by default. 年をパースする際に使われる :func:`~time.strftime` フォーマットを返し ます。デフォルトでは :attr:`YearMixin.year_format` が返されます。 .. method:: get_year() .. Returns the year for which this view will display data. Tries the following sources, in order: ビューが表示するデータ用の年を返します。以下の方法で順に試されます。 .. * 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. * :attr:`YearMixin.year` 属性の値 * URL パターンで取得された `year` 引数の値 * GET クエリ引数の `year` の値 .. Raises a 404 if no valid year specification can be found. 妥当な年を特定できなかった場合は 404 が発生します。 .. MonthMixin ~~~~~~~~~~ MonthMixin ~~~~~~~~~~ .. class:: MonthMixin() .. A mixin that can be used to retrieve and provide parsing information for a month component of a date. ある日の、月に関する要素のパースされた情報を取得、提供するために使われる Mixin です。 .. attribute:: month_format .. The :func:`~time.strftime` format to use when parsing the month. By default, this is ``'%b'``. 月をパースする際に使われる :func:`~time.strftime` フォーマットです。 デフォルトでは ``'%b'`` です。 .. attribute:: 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. **オプション** (文字列としての) 月の値です。デフォルトでは ``None`` が 設定されています。この場合、月は他の手段によって決定されます。 .. method:: get_month_format() .. Returns the :func:`~time.strftime` format to use when parsing the month. Returns :attr:`MonthMixin.month_format` by default. :func:`~time.strftime` フォーマットを返します。これは月をパースする際に 使われます。デフォルトでは :attr:`MonthMixin.month_format` が返されます。 .. method:: get_month() .. Returns the month for which this view will display data. Tries the following sources, in order: ビューが表示するデータ用の月を返します。以下の方法で順に試されます。 .. * 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. * :attr:`MonthMixin.month` 属性の値 * URL パターンで取得された `month` 引数の値 * GET クエリ引数の `month` の値 .. Raises a 404 if no valid month specification can be found. 妥当な月を特定できなかった場合は 404 が発生します。 .. method:: get_next_month(date) .. Returns a date object containing the first day of the month after the date provided. Returns ``None`` if mixed with a view that sets ``allow_future = False``, and the next month is in the future. If ``allow_empty = False``, returns the next month that contains data. 引数で与えられた日付の、翌月の初日を含む日付オブジェクトを返します。 ``allow_future = False`` がビューに設定されており、翌月が未来にある 場合は ``None`` を返します。 ``allow_empty = False`` の場合は、翌月を データを含んだ状態で返します。 .. method:: get_prev_month(date) .. 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. 与えられた日付の前月の初日を含む日付オブジェクトを返します。 ``allow_empty = False`` の場合は、データを含んだ前月を返します。 .. DayMixin ~~~~~~~~~ DayMixin ~~~~~~~~~ .. class:: DayMixin() .. A mixin that can be used to retrieve and provide parsing information for a day component of a date. 日付における日 (day) 要素のためのパースされた情報を取得し、提供する Mixin です。 .. attribute:: day_format .. The :func:`~time.strftime` format to use when parsing the day. By default, this is ``'%d'``. 日をパースする際に使われる :func:`~time.strftime` フォーマットです。 デフォルトでは ``'%d'`` です。 .. attribute:: day .. **Optional** The value for the day (as a string). By default, set to ``None``, which means the day will be determined using other means. **オプション** (文字列としての) 日の値です。デフォルトでは ``None`` が 設定されています。この場合、年は他の手段によって決定されます。 .. method:: get_day_format() .. Returns the :func:`~time.strftime` format to use when parsing the day. Returns :attr:`DayMixin.day_format` by default. :func:`~time.strftime` フォーマットを返します。これは日をパースする際に 使われます。デフォルトでは :attr:`DayMixin.day_format` が返されます。 .. method:: get_day() .. Returns the day for which this view will display data. Tries the following sources, in order: ビューが表示するデータ用の日を返します。以下の方法で順に試されます。 .. * 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. * :attr:`DayMixin.year` 属性の値 * URL パターンで取得された `day` 引数の値 * GET クエリ引数の `day` の値 .. Raises a 404 if no valid day specification can be found. 妥当な日を特定できなかった場合は 404 が発生します。 .. method:: get_next_day(date) .. Returns a date object containing the next day after the date provided. Returns ``None`` if mixed with a view that sets ``allow_future = False``, and the next day is in the future. If ``allow_empty = False``, returns the next day that contains data. 引数で与えられた日付の、次の日を含む日付オブジェクトを返します。 ``allow_future = False`` がビューに設定されており、翌日が未来にある 場合は ``None`` を返します。 ``allow_empty = False`` の場合は、翌日の データを含んだ状態で返します。 .. method:: get_prev_day(date) .. Returns a date object containing the previous day. If ``allow_empty = False``, returns the previous day that contained data. 与えられた日付の前日を含む日付オブジェクトを返します。 ``allow_empty = False`` の場合は、データを含んだ前日を返します。 .. WeekMixin ~~~~~~~~~ WeekMixin ~~~~~~~~~ .. class:: WeekMixin() .. A mixin that can be used to retrieve and provide parsing information for a week component of a date. 日付における週 (week) 要素のためのパースされた情報を取得し、提供する Mixin です。 .. attribute:: week_format .. The :func:`~time.strftime` format to use when parsing the week. By default, this is ``'%U'``. 週をパースする際に使われる :func:`~time.strftime` フォーマットです。 デフォルトでは ``'%U'`` です。 .. attribute:: 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. **オプション** (文字列としての) 週の値です。デフォルトでは ``None`` が 設定されています。この場合、週は他の手段によって決定されます。 .. method:: get_week_format() .. Returns the :func:`~time.strftime` format to use when parsing the week. Returns :attr:`WeekMixin.week_format` by default. :func:`~time.strftime` フォーマットを返します。これは週をパースする際に 使われます。デフォルトでは :attr:`WeekMixin.week_format` が返されます。 .. method:: get_week() .. Returns the week for which this view will display data. Tries the following sources, in order: ビューが表示するデータ用の週を返します。以下の方法で順に試されます。 .. * 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. * :attr:`WeekMixin.month` 属性の値 * URL パターンで取得された `week` 引数の値 * GET クエリ引数の `week` の値 .. Raises a 404 if no valid week specification can be found. 妥当な週を特定できなかった場合は 404 が発生します。 .. DateMixin ~~~~~~~~~ DateMixin ~~~~~~~~~ .. class:: DateMixin() .. A mixin class providing common behavior for all date-based views. すべての日付ベースビュー (date-based views) のための共通の振る舞いを提供 する Mixin クラスです。 .. Attribute:: Date_Field .. 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. ``QuerySet`` 内のモデルの ``DateField`` か ``DateTimeField`` の名前 です。このモデルは日付ベースの記事においてオブジェクトのページを決定 するために使われます。 .. attribute:: allow_future .. 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``. "未来の (future)" オブジェクトをページ内に含めるかどうかを指定するブール 値です。 "未来" というのは ``date_filed`` で指定されるフィールド内の オブジェクトが、現在の日付/時刻よりも大きい値を持っているということ です。デフォルトでは ``False`` です。 .. method:: get_date_field() .. Returns the name of the field that contains the date data that this view will operate on. Returns :attr:`DateMixin.date_field` by default. ビューが扱う日付データを含むフィールドの名前を返します。デフォルトでは :attr:`DateMixin.date_field` です。 .. method:: get_allow_future() .. 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 :attr:`DateMixin.allow_future` by default. ページに "未来の" オブジェクトを含めるかどうかを決定します。"未来" と いうのは ``date_filed`` で指定されるフィールド内のオブジェクトが、現在の 日付/時刻よりも大きい値を持っているということです。デフォルトでは :attr:`DateMixin.allow_future` が返されます。 .. BaseDateListView ~~~~~~~~~~~~~~~~ BaseDateListView ~~~~~~~~~~~~~~~~ .. class:: BaseDateListView() .. 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. すべての日付ベースビューのための共通の振る舞いを提供する基底クラスです。 通常 :class:`~django.views.generic.dates.BaseDateListView` はインスタンス 化しません。これのサブクラスの 1 つをインスタンス化することになるでしょう。 .. 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. このビュー (とサブクラス) が実行されている間、 ``self.object_list`` は オブジェクトのリストを含みます。このオブジェクトのリストはビューが扱うもので あり、 ``self.date_list`` は日付のリストを含みます。これはどのデータが利用 可能かを表しています。 .. **Mixins** **Mixin** * :class:`~django.views.generic.dates.DateMixin` * :class:`~django.views.generic.list.MultipleObjectMixin` .. attribute:: allow_empty .. A boolean specifying whether to display the page if no objects are 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``. 利用可能なオブジェクトが無い際に、ページを表示するかどうかを指定する ブール値です。 ``True`` であり、オブジェクトが利用できない場合、ビュー は 404 を送出する代わりに空のページを表示します。デフォルトでこれは ``False`` です。 .. method:: get_dated_items(): .. Returns a 3-tuple containing (``date_list``, ``object_list``, ``extra_context``). (``date_list``, ``object_list``, ``extra_context``) を含む 3 要素の タプルを返します。 .. ``date_list`` is the list of dates for which data is available. ``object_list`` is the list of objects. ``extra_context`` is a dictionary of context data that will be added to any context data provided by the :class:`~django.views.generic.list.MultipleObjectMixin`. ``date_list`` はどのデータが利用可能かを表す日付のリストです。 ``object_list`` はオブジェクトのリストです。 ``extra_context`` は コンテキストデータの辞書です。これには :class:`~django.views.generic.list.MultipleObjectMixin` に提供される すべてのコンテキストデータが加えられるでしょう。 .. method:: get_dated_queryset(**lookup) .. Returns a queryset, filtered using the query arguments defined by ``lookup``. Enforces any restrictions on the queryset, such as ``allow_empty`` and ``allow_future``. ``lookup`` によって明示されたクエリ引数を使ってフィルタされたクエリ セットを返します。クエリセットのすべての制限について適応されます。 例えば ``allow_empty`` や ``allow_future`` があります。 .. method:: get_date_list(queryset, date_type) .. 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. See :meth:`~django.db.models.query.QuerySet.dates()` for the ways that the ``date_type`` argument can be used. ``date_type`` タイプの日付のリストを返します。これは ``queryset`` が んでいる要素になります。例えば ``get_date_list(qs, 'year')`` は ``qs`` が持つ要素から、年のリストを返します。 ``date_type`` 引数の使われ方 については :meth:`~django.db.models.query.QuerySet.dates()` を見てくだ さい。 .. Generic views ============= 汎用ビュー ========== .. Simple generic views -------------------- 単純な汎用ビュー ---------------- .. currentmodule:: django.views.generic.base .. View ~~~~ View ~~~~ .. class:: View() .. The master class-based base view. All other generic class-based views inherit from this base class. クラスベースビューの大元です。すべてのクラスベース汎用ビューはこの基本クラス を受け継いでいます。 .. 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). :class:`~django.views.generic.base.View` にある各リクエストは独自の状態を 持ちます。なので、インスタンスに状態変数 (state variables) を保持しても 安全です (例えば ``self.foo = 3`` はスレッドセーフな (thread-safe) 処理に なります) 。 .. A class-based view is deployed into a URL pattern using the :meth:`~View.as_view()` classmethod:: urlpatterns = patterns('', (r'^view/$', MyView.as_view(size=42)), ) クラスベースビューは :meth:`~View.as_view()` クラスメソッドを用いて URL パターン内に配置されます:: urlpatterns = patterns('', (r'^view/$', MyView.as_view(size=42)), ) .. 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``. :meth:`~View.as_view()` に渡されるすべての引数は、リクエストを処理する インスタンスに配置されます。先の例が意味するのは、 ``MyView`` へのすべての リクエストは ``self.size`` に問い合わせできるということです。 .. .. admonition:: Thread safety with view arguments 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. .. admonition:: ビューの引数におけるスレッドセーフ ビューに渡される引数はビューの全インスタンス間で共有されます。これが 意味するのは、リスト、辞書、そしてすべてのオブジェクトをビューに対する 引数として使うべきでないということです。それをした場合、ビューに訪れた あるユーザのアクションが、同じビューに訪れた次のユーザにも影響してしまい ます。 .. method:: dispatch(request, *args, **kwargs) .. The ``view`` part of the view -- the method that accepts a ``request`` argument plus arguments, and returns a HTTP response. ビューにおける ``view`` の部分です。 ``request`` を含む引数を受け取り HTTP レスポンスを返すメソッドです。 .. 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. デフォルトの機能は、 HTTP メソッドを調べ、 HTTP メソッドに対応するメソッ ドへ委任します。 ``GET`` は :meth:`~View.get()` に委任されます。 ``POST`` は :meth:`~View.post()` 、などです。 .. 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. さらにデフォルトでは ``request`` 、 ``args`` と ``kwargs`` をインス タンスの変数として設定します。なので、ビューのメソッドはリクエストの 詳細を知ることができます。このリクエストはビューを呼び出すのに作られた ものです。 .. method:: http_method_not_allowed(request, *args, **kwargs) .. If the view was called with HTTP method it doesn't support, this method is called instead. ビューがサポートしていない HTTP メソッドが呼び出された際は、代わりに このメソッドが呼び出されます。 .. The default implementation returns ``HttpResponseNotAllowed`` with list of allowed methods in plain text. デフォルトの機能では ``HttpResponseNotAllowed`` が返されます。その際、 許可されてるメソッドのリストをプレーンテキストも同時に返します。 .. TemplateView ~~~~~~~~~~~~ TemplateView ~~~~~~~~~~~~ .. class:: TemplateView() .. Renders a given template, passing it a ``{{ params }}`` template variable, which is a dictionary of the parameters captured in the URL. 与えられたテンプレートをレンダリングします。その際それを ``{{ params }}`` テンプレート引数で渡します。 URL でキャプチャされた引数の辞書になります。 .. **Mixins** **Mixin** * :class:`django.views.generic.base.TemplateResponseMixin` .. attribute:: template_name .. The full name of a template to use. 使いたいテンプレートのフルネームです。 .. method:: get_context_data(**kwargs) .. Return a context data dictionary consisting of the contents of ``kwargs`` stored in the context variable ``params``. コンテキストデータ辞書を返します。この辞書は ``params`` コンテキスト変数 を含む ``kwargs`` の内容から構成されています。 .. **Context** **コンテキスト** .. * ``params``: The dictionary of keyword arguments captured from the URL pattern that served the view. * ``params``: ビューを起こした URL パターンからキャプチャされたキーワード 引数の辞書です。 .. RedirectView ~~~~~~~~~~~~ RedirectView ~~~~~~~~~~~~ .. class:: RedirectView() .. Redirects to a given URL. 与えられた URL にリダイレクトします。 .. 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. 与えられる URL は辞書スタイル (dictionary-style) のフォーマットを含んでいる でしょう。これは URL からキャプチャしたパラメータを含んでいます。キーワード 補完は (引数が一切渡されなくても) **常に** 完了しています。ですので、 URL 内の全 ``"%"`` キャラクタは、 ``"%%"`` として書かれるべきです。そうすれば Python は出力の際に、それらを単一のパーセント記号として変換します。 .. If the given URL is ``None``, Django will return an ``HttpResponseGone`` (410). 与えられた URL が ``None`` の場合は、 Djangoは ``HttpResponseGone`` (410) を返します。 .. attribute:: url .. The URL to redirect to, as a string. Or ``None`` to raise a 410 (Gone) HTTP error. リダイレクトされる URL で、文字列です。 ``None`` では 410 (Gone) HTTP エラーを送出します。 .. attribute:: permanent .. 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``. リダイレクトが永続的なものかどうかです。ここで唯一の違いは返される HTTP ステータスコードです。 ``True`` の場合、リダイレクトは 301 ステータス コードを使います。 ``False`` の場合、 302 ステータスコードを使います。 デフォルトで ``permanent`` は ``True`` です。 .. attribute:: query_string .. 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``. GET クエリ文字列を新しいロケーションに伝えるかどうかを選択します。 ``True`` の場合、クエリ文字列は URL に付加されます。 ``False`` の場合 、クエリ文字列は捨てられます。デフォルトで ``query_string`` は ``False`` です。 .. method:: get_redirect_url(**kwargs) .. Constructs the target URL for redirection. リダイレクションの対象となる URL を返します。 .. 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. デフォルトの機能では :attr:`~RedirectView.url` 文字列を元に、 ``%`` パラメータで拡張されて使われます。 :attr:`~RedirectView.query_string` に要求された場合は、クエリ文字列の 付加も同様に行われます。 .. Detail views ------------ 詳細なビュー ------------ .. currentmodule:: django.views.generic.detail .. DetailView ~~~~~~~~~~ DetailView ~~~~~~~~~~ .. class:: BaseDetailView() .. class:: DetailView() .. A page representing an individual object. 個別のオブジェクトを表現するページです。 .. While this view is executing, ``self.object`` will contain the object that the view is operating upon. このビューが実行されている間、 ``self.object`` はビューが操作しているオブ ジェクトを含みます。 .. :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`. :class:`~django.views.generic.base.BaseDetailView` は :class:`~django.views.generic.base.DetailView` と同じ振る舞いを提供します。 しかし、 :class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.detail.SingleObjectMixin` * :class:`django.views.generic.detail.SingleObjectTemplateResponseMixin` .. List views ---------- リストビュー ------------ .. currentmodule:: django.views.generic.list .. ListView ~~~~~~~~ ListView ~~~~~~~~ .. class:: BaseListView() .. class:: 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. このビューが実行されている間、 ``self.object_list`` はビューが操作している オブジェクトのリスト (必須ではないですが、常にクエリセット) を含みます。 .. :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`. :class:`~django.views.generic.list.BaseListView` は :class:`~django.views.generic.list.ListView` と同じ振る舞いを提供します。 しかし、 :class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.list.MultipleObjectMixin` * :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin` .. Editing views ------------- 編集用ビュー ------------ .. currentmodule:: django.views.generic.edit .. FormView ~~~~~~~~ FormView ~~~~~~~~ .. class:: BaseFormView() .. class:: FormView() .. A view that displays a form. On error, redisplays the form with validation errors; on success, redirects to a new URL. フォームを表示するビューです。エラーの場合、フォームが検証エラーとともに 再表示されます。成功した場合は新しい URL にリダイレクトされます。 .. :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`. :class:`~django.views.generic.edit.BaseFormView` は :class:`~django.views.generic.edit.FormView` と同じ振る舞いを提供します。 しかし、 :class:`~django.views.generic.base.TemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.edit.FormMixin` * :class:`django.views.generic.edit.ProcessFormView` .. CreateView ~~~~~~~~~~ CreateView ~~~~~~~~~~ .. class:: BaseCreateView() .. class:: 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. オブジェクトを作成するためのフォームを表示するビューです。フォームが検証 エラーとともに再表示されます (何かあった場合) 、そしてオブジェクトが記録 されます .. :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`. :class:`~django.views.generic.edit.BaseCreateView` は :class:`~django.views.generic.edit.CreateView` と同じ振る舞いを提供します。 しかし、 :class:`~django.views.generic.base.TemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.edit.ModelFormMixin` * :class:`django.views.generic.edit.ProcessFormView` .. UpdateView ~~~~~~~~~~ UpdateView ~~~~~~~~~~ .. class:: BaseUpdateView() .. class:: 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). 存在するオブジェクトを編集するためのフォームを表示するビューです。フォームが 検証エラーとともに再表示されます (何かあった場合) 、そしてオブジェクトの 変更点が記録されます。これはオブジェクトのモデルクラスの自動生成フォームを 使っています (フォームクラスが手動で指定されていない場合) 。 .. :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`. :class:`~django.views.generic.edit.BaseUpdateView` は :class:`~django.views.generic.edit.UpdateView` と同じ振る舞いを提供します。 しかし、 :class:`~django.views.generic.base.TemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.edit.ModelFormMixin` * :class:`django.views.generic.edit.ProcessFormView` .. DeleteView ~~~~~~~~~~ DeleteView ~~~~~~~~~~ .. class:: BaseDeleteView() .. class:: 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 確認用ページを表示し、存在するオブジェクトを削除するビューです。与えられた オブジェクトはリクエストメソッドが ``POST`` の場合にのみ削除されます。この ビューが ``GET`` を通じて与えられた場合、確認用ページを表示します。この ページは同ページに POST するフォームを含みます。 .. :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`. :class:`~django.views.generic.edit.BaseDeleteView` は :class:`~django.views.generic.edit.DeleteView` と同じ振る舞いを提供します。 しかし、 :class:`~django.views.generic.base.TemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.edit.DeletionMixin` * :class:`django.views.generic.detail.BaseDetailView` .. **Notes** **Notes** .. * The delete confirmation page displayed to a GET request uses a ``template_name_suffix`` of ``'_confirm_delete'``. * GET リクエスト時に表示される削除確認ページは ``'_confirm_delete'`` という ``template_name_suffix`` を使います。 .. 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. 日付ベース汎用ビュー (モジュール :mod:`django.views.generic.dates` にあります) は日付ベースのデータをドリルダウン (drilldown) ページに表示するビューです。 .. currentmodule:: django.views.generic.dates .. ArchiveIndexView ~~~~~~~~~~~~~~~~ ArchiveIndexView ~~~~~~~~~~~~~~~~ .. class:: BaseArchiveIndexView() .. class:: ArchiveIndexView() .. 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``. 日付における "最新 (latest)" オブジェクトを表示するトップレベルのインデック スページです。オブジェクトが *未来の* 日付にある場合は、 ``allow_future`` を ``True`` に設定していない限り含まれません。 .. :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`. :class:`~django.views.generic.dates.BaseArchiveIndexView` は :class:`~django.views.generic.dates.ArchiveIndexView` と同じ振る舞いを提供 します。しかし、 :class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.dates.BaseDateListView` * :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin` .. **Notes** **Notes** .. * Uses a default ``context_object_name`` of ``latest``. * Uses a default ``template_name_suffix`` of ``_archive``. * デフォルトで ``context_object_name`` は ``latest`` を使います。 * デフォルトで ``template_name_suffix`` は ``_archive`` を使います。 .. YearArchiveView ~~~~~~~~~~~~~~~ YearArchiveView ~~~~~~~~~~~~~~~ .. class:: BaseYearArchiveView() .. 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``. 与えられた年の特定の月すべてを表示する年単位のアーカイブページを表示します。 *未来の* 日付のオブジェクトは ``allow_future`` を ``True`` にしない限り表示 されません。 .. :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`. :class:`~django.views.generic.dates.BaseYearArchiveView` は :class:`~django.views.generic.dates.YearArchiveView` と同じ振る舞いを提供 します。しかし、 :class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin` * :class:`django.views.generic.dates.YearMixin` * :class:`django.views.generic.dates.BaseDateListView` .. attribute:: 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. By default, this is ``False``. この年のためにオブジェクトの全リストを取得し、テンプレートに渡すかどうか を指定するブール値です。 ``True`` ならオブジェクトのリストはコンテキスト で使用できるようになります。デフォルトでは ``False`` です。 .. method:: get_make_object_list() .. 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. オブジェクトのリストがコンテキストの一部として返されるかどうか判断します 。 ``False`` の場合、 ``None`` クエリセットがオブジェクトのリストとして 使われます。 .. **Context** **コンテキスト** .. 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: (:class:`django.views.generic.dates.BaseDateListView` 経由で) :class:`django.views.generic.list.MultipleObjectMixin` に提供されるコン テキストに加えて、テンプレートコンテキストは以下のようなものがあります: .. * ``date_list``: A ``DateQuerySet`` object containing all months that have objects available according to ``queryset``, represented as ``datetime.datetime`` objects, in ascending order. * ``date_list``: ``queryset`` 内で有効なオブジェクトを持つすべての月を含む ``DateQuerySet`` オブジェクトです。 ``datetime.datetime`` オブジェクト として昇順に表現されます。 .. * ``year``: The given year, as a four-character string. * ``year``: 与えられた年です。4 キャラクター文字列です。 .. **Notes** **Notes** .. * Uses a default ``template_name_suffix`` of ``_archive_year``. * デフォルトで ``template_name_suffix`` は ``_archive_year`` が使われます。 .. MonthArchiveView ~~~~~~~~~~~~~~~~ MonthArchiveView ~~~~~~~~~~~~~~~~ .. class:: BaseMonthArchiveView() .. class:: MonthArchiveView() .. 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``. 与えられた月すべてのオブジェクトを表示する月単位のアーカイブページを表示 します。*未来の* 日付のオブジェクトは ``allow_future`` を ``True`` にしない 限り表示されません。 .. :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`. :class:`~django.views.generic.dates.BaseMonthArchiveView` は :class:`~django.views.generic.dates.MonthArchiveView` と同じ振る舞いを提供 します。しかし、 :class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin` * :class:`django.views.generic.dates.YearMixin` * :class:`django.views.generic.dates.MonthMixin` * :class:`django.views.generic.dates.BaseDateListView` .. **Context** **コンテキスト** .. 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: (:class:`django.views.generic.dates.BaseDateListView` 経由で) :class:`django.views.generic.list.MultipleObjectMixin` に提供されるコン テキストに加えて、テンプレートコンテキストは以下のようなものがあります: .. * ``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. * ``date_list``: 与えられた月の有効なオブジェクトを持つ、すべての日を含む ``DateQuerySet`` オブジェクトです。 ``queryset`` に一致しており、 ``datetime.datetime`` オブジェクトを昇順で表現しています。 .. * ``month``: A ``datetime.date`` object representing the given month. * ``month``: 与えられた月を表現する ``datetime.date`` オブジェクトです。 .. * ``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``. * ``next_month``: 翌月の初日を表現する ``datetime.datetime`` オブジェクト です。もし翌月が未来にあるなら、 ``None`` になります。 .. * ``previous_month``: A ``datetime.date`` object representing the first day of the previous month. Unlike ``next_month``, this will never be ``None``. * ``previous_month``: 前月の初日を表現する ``datetime.date`` オブジェクト です。 ``next_month`` とは違いこれは ``None`` になりません。 .. **Notes** **Notes** .. * Uses a default ``template_name_suffix`` of ``_archive_month``. * ``template_name_suffix`` はデフォルトで ``_archive_month`` を使います。 .. WeekArchiveView ~~~~~~~~~~~~~~~ WeekArchiveView ~~~~~~~~~~~~~~~ .. class:: BaseWeekArchiveView() .. 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``. 与えられた週すべてのオブジェクトを表示する週単位のアーカイブページを表示 します。*未来の* 日付のオブジェクトは ``allow_future`` を ``True`` にしない 限り表示されません。 .. :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`. :class:`~django.views.generic.dates.BaseWeekArchiveView` は :class:`~django.views.generic.dates.WeekArchiveView` と同じ振る舞いを提供 します。しかし、 :class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin` * :class:`django.views.generic.dates.YearMixin` * :class:`django.views.generic.dates.MonthMixin` * :class:`django.views.generic.dates.BaseDateListView` .. **Context** **コンテキスト** .. 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: (:class:`django.views.generic.dates.BaseDateListView` 経由で) :class:`django.views.generic.list.MultipleObjectMixin` に提供されるコン テキストに加えて、テンプレートコンテキストは以下のようなものがあります: .. * ``week``: A ``datetime.date`` object representing the first day of the given week. * ``week``: 与えられた週の初日を表現する ``datetime.date`` オブジェクトです。 .. **Notes** **Notes** .. * Uses a default ``template_name_suffix`` of ``_archive_week``. * ``template_name_suffix`` はデフォルトで ``_archive_week`` を使います。 .. DayArchiveView ~~~~~~~~~~~~~~ .. class:: BaseDayArchiveView() .. class:: DayArchiveView() .. 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``. 与えられた日のオブジェクトをすべて表示する日単位のアーカイブのページです。 その日が未来にある場合には 404 エラーが返されます。 ``allow_future`` が ``True`` でない限り、オブジェクトが未来にあるかどうか気をつける必要があり ます。 .. :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`. :class:`~django.views.generic.dates.BaseDayArchiveView` は :class:`~django.views.generic.dates.DayArchiveView` と同じ振る舞いを提供 します。しかし、 :class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :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` .. **Context** **コンテキスト** .. 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: (:class:`django.views.generic.dates.BaseDateListView` 経由で) :class:`django.views.generic.list.MultipleObjectMixin` に提供されるコン テキストに加えて、テンプレートコンテキストは以下のようなものがあります: .. * ``day``: A ``datetime.date`` object representing the given day. * ``day``: 与えられた日を表現する ``datetime.date`` オブジェクト .. * ``next_day``: A ``datetime.date`` object representing the next day. If the next day is in the future, this will be ``None``. * ``next_day``: 翌日を表現する ``datetime.date`` オブジェクトです。もし その翌日が未来にある場合は ``None`` になります。 .. * ``previous_day``: A ``datetime.date`` object representing the previous day. Unlike ``next_day``, this will never be ``None``. * ``previous_day``: 前日を表現する ``datetime.date`` オブジェクトです。 ``next_day`` のように ``None`` にはなりません。 .. * ``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``. * ``next_month``: 翌月の初日を表現する ``datetime.date`` オブジェクトです。 もし翌月が未来にあるなら、 ``None`` になります。 .. * ``previous_month``: A ``datetime.date`` object representing the first day of the previous month. Unlike ``next_month``, this will never be ``None``. * ``previous_month``: 前月の初日を表現する ``datetime.date`` オブジェクト です。 ``next_month`` のように ``None`` にはなりません。 .. **Notes** **Notes** .. * Uses a default ``template_name_suffix`` of ``_archive_day``. * デフォルトで ``template_name_suffix`` は ``_archive_day`` を使います。 .. TodayArchiveView ~~~~~~~~~~~~~~~~ TodayArchiveView ~~~~~~~~~~~~~~~~ .. class:: BaseTodayArchiveView() .. class:: TodayArchiveView() .. A day archive page showing all objects for *today*. This is exactly the same as :class:`django.views.generic.dates.DayArchiveView`, except today's date is used instead of the ``year``/``month``/``day`` arguments. **今日 (today)** のすべてのオブジェクトを表示する日単位のアーカイブページ です。これはまさに :class:`django.views.generic.dates.DayArchiveView` と 同じですが、 ``year``/``month``/``day`` 属性の代わりに今日の日付が使われる 点が違います。 .. :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`. :class:`~django.views.generic.dates.BaseTodayArchiveView` は :class:`~django.views.generic.dates.TodayArchiveView` と同じ振る舞いを提供 します。しかし、 :class:`~django.views.generic.list.MultipleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :class:`django.views.generic.list.MultipleObjectTemplateResponseMixin` * :class:`django.views.generic.dates.BaseDayArchiveView` .. DateDetailView ~~~~~~~~~~~~~~ DateDetailView ~~~~~~~~~~~~~~ .. class:: BaseDateDetailView() .. class:: DateDetailView() .. 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``. 個別オブジェクトを表現するページです。オブジェクトが持つ日付の値が未来にある 場合、デフォルトでは 404 エラーを送出します。 ``allow_future`` を ``True`` に設定することで 404 エラーを送出しません。 .. :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`. :class:`~django.views.generic.dates.BaseDateDetailView` は :class:`~django.views.generic.dates.DateDetailView` と同じ振る舞いを提供 します。しかし、 :class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin` を含んでいません。 .. **Mixins** **Mixin** * :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`