... ョンのアクセサ): content_type context_object_name [ get_context_object_name() ] extra_context http_method_names model pk_url_kwarg query_pk_and_slug queryset [ get_queryset() ] response_class [ render_to_response() ] slug_field [ get_slug_field() ] slug ... _url_kwarg template_engine template_name [ get_template_names() ] template_name_field template_name_suffix メソッド as_view() dispatc ... _template_names() ] メソッド as_view() dispatch() form_invalid() form_valid() get() get_context_data() get_form() get_form_kwargs() http_method_not_allowed() post() put() setup() CreateView class CreateView 属性 (とオプションのアクセサ): content_type ... ... してください。 slug_field スラグを含むモデル上のフィールドの名前です。デフォルトでは、 slug_field は 'slug' です。 slug_url_kwarg スラグを含む URLConf キーワード引数の名前です。デフォルトでは、 slug_url_kwarg は 'slug' です。 pk_url_kwarg プライマリキー ... を含む URLConf キーワード引数の名前です。デフォルトでは、 pk_url_kwarg は 'pk' です。 context_object_name コンテキストで使用する変数名を指定します。 query_pk_and_slug True の場合、 get_object() ... ソースとして使用されます。 それ以外の場合は、 get_queryset() が使用されます。 get_object() は、ビューへの引数の中から pk_url_kwarg 引数を探します。 この引数が見つかった場合、このメソッドはその値を使用してプライマリキーベースのルックアップを実行します。 ... ... alue using URLValidator before displaying the clickable link. You may customize the validator by passing a validator_class kwarg to AdminURLFieldWidget.__init__() , e.g. when using formfield_overrides . ... ... alue using URLValidator before displaying the clickable link. You may customize the validator by passing a validator_class kwarg to AdminURLFieldWidget.__init__() , e.g. when using formfield_overrides . Patched bundled jQuery for CVE-2019-11358: Proto ... ... alue using URLValidator before displaying the clickable link. You may customize the validator by passing a validator_class kwarg to AdminURLFieldWidget.__init__() , e.g. when using formfield_overrides . Patched bundled jQuery for CVE-2019-11358: Proto ... ... e to filter for any of a group of values. You need to override the expected_parameters method, and then specify the lookup_kwargs attribute with the appropriate field name. By default, multiple values in the query string will be separated with commas, ... s. list_separator = "|" def __init__ ( self , field , request , params , model , model_admin , field_path ): self . lookup_kwarg = " %s __in" % field_path super () . __init__ ( field , request , params , model , model_admin , field_path ) def expected ... _parameters ( self ): return [ self . lookup_kwarg ] 注釈 GenericForeignKey フィールドはサポートされていません。 リストフィルタは通常、フィルタに複数の選択肢がある場合にのみ ... ... の制限を最大で paginate_orphans の値まで拡張し、最後のページでほんの少しのオブジェクトしか表示されないことを防ぎます。 page_kwarg ページのパラメータに使用する名前を指定する文字列です。ビューは ( request.GET を通じた) クエリ文字列パラメータ、もしくはURL ... conf 内で指定した kwarg が有効になっていることを必要とします。デフォルトは page です。 paginator_class ページ分割に使用する paginator クラス。デフ ... れます。たとえば、 Article モデルなら article_list という名前のコンテキストオブジェクトを保持します。 get_context_data ( ** kwargs ) オブジェクトのリストを表示するためのコンテキストデータを返します。 コンテキスト object_list : このビューが表示しているオ ... ... ルスタックをカプセル化した、トレースバックオブジェクト。 例外が発生しなかった場合、 exc_info は None になります。 json ( ** kwargs ) JSON としてパースされた、レスポンスの本文です。追加のキーワード引数が json.loads() に渡されます。たとえば、次のようにな ... 存在する場合、 append と prepend は何もしません。同様に、値が存在しない場合、 remove は何もしません。 override_settings ( ** kwargs ) [ソース] In case you want to override a setting for a test method, Django provides the override_settings() decorator : ... ent . get ( "/sekrit/" ) self . assertRedirects ( response , "/other/login/?next=/sekrit/" ) modify_settings ( * args , ** kwargs ) [ソース] 同様に、Django には modify_settings() デコレータがあります: from django.test import TestCase , modify_settings ... ... n extended to the trans and blocktrans template tags using the new context keyword. Customizable SingleObjectMixin URLConf kwargs Two new attributes, pk_url_kwarg and slug_url_kwarg , have been added to SingleObjectMixin to enable the customization of ... ded to template.Library to ease the creation of template tags that store data in a specified context variable. *args and **kwargs support for template tag helper functions The simple_tag , inclusion_tag and newly introduced assignment_tag template hel ... accept any number of positional or keyword arguments. For example: @register . simple_tag def my_tag ( a , b , * args , ** kwargs ): warning = kwargs [ "warning" ] profile = kwargs [ "profile" ] ... return ... Then, in the template, any number of argu ... ... odels import Book , Publisher class PublisherDetailView ( DetailView ): model = Publisher def get_context_data ( self , ** kwargs ): # Call the base implementation first to get a context context = super () . get_context_data ( ** kwargs ) # Add in a Q ... には様々な便利な値が格納されていることです。request ( self.request )、位置引数 ( self.args )、そして、キーワード引数 ( self.kwargs ) が、URLconf からキャプチャされてきています。 ここでは、次のように URLconf に1つのキャプチャグループがあるとしましょう。 ... books/books_by_publisher.html" def get_queryset ( self ): self . publisher = get_object_or_404 ( Publisher , name = self . kwargs [ "publisher" ]) return Book . objects . filter ( publisher = self . publisher ) queryset の選択に追加のロジックを加えるた ... 2026年10月08日