... () http_method_not_allowed() setup() TemplateView ¶ class TemplateView ¶ 属性 (とオプションのアクセサ): content_type extra_context http_method_names response_class [ render_to_response() ] template_engine template_name [ get_template_names() ] メソッド ... as_view() dispatch() get() get_context_data() head() http_method_not_allowed() render_to_response() setup() RedirectView ¶ class RedirectView ¶ 属性 (とオプション ... () options() post() put() setup() 詳細ビュー ¶ DetailView ¶ class DetailView ¶ 属性 (とオプションのアクセサ): content_type context_object_name [ get_context_object_name() ] extra_context http_method_names model pk_url_kwarg query_pk_and_slug queryset [ ... ... () http_method_not_allowed() setup() TemplateView ¶ class TemplateView ¶ 属性 (とオプションのアクセサ): content_type extra_context http_method_names response_class [ render_to_response() ] template_engine template_name [ get_template_names() ] メソッド ... as_view() dispatch() get() get_context_data() head() http_method_not_allowed() render_to_response() setup() RedirectView ¶ class RedirectView ¶ 属性 (とオプション ... () options() post() put() setup() 詳細ビュー ¶ DetailView ¶ class DetailView ¶ 属性 (とオプションのアクセサ): content_type context_object_name [ get_context_object_name() ] extra_context http_method_names model pk_url_kwarg query_pk_and_slug queryset [ ... ... ムを使うには3つのステップがあります: Engine を設定します。 テンプレートコードを Template にコンパイルします。 テンプレートを Context においてレンダリングします。 これらの各ステップで、Django プロジェクトは通常、テンプレートシステムの低レベルの API ではなく ... mplate を返します。 前のステップで取得した Template には render() メソッドがあり、コンテキストと場合によってはリクエストを Context に集約し、その下にある Template にレンダリングを委譲します。 エンジンを設定する ¶ もし DjangoTemplates バックエンドを使って ... 後述する属性のデフォルトは DjangoTemplates で渡されたもので上書きされます。 class Engine ( dirs = None , app_dirs = False , context_processors = None , debug = False , loaders = None , string_if_invalid = '' , file_charset = 'utf-8' , libraries = None , ... ... ムを使うには3つのステップがあります: Engine を設定します。 テンプレートコードを Template にコンパイルします。 テンプレートを Context においてレンダリングします。 これらの各ステップで、Django プロジェクトは通常、テンプレートシステムの低レベルの API ではなく ... mplate を返します。 前のステップで取得した Template には render() メソッドがあり、コンテキストと場合によってはリクエストを Context に集約し、その下にある Template にレンダリングを委譲します。 エンジンを設定する ¶ もし DjangoTemplates バックエンドを使って ... 後述する属性のデフォルトは DjangoTemplates で渡されたもので上書きされます。 class Engine ( dirs = None , app_dirs = False , context_processors = None , debug = False , loaders = None , string_if_invalid = '' , file_charset = 'utf-8' , libraries = None , ... ... mat_html() を使うことを強く推奨します。 テンプレートタグの中からコンテキストにアクセスしたい場合、タグを登録する際に takes_context 引数を使うことでできるようになります。 @register . simple_tag ( takes_context = True ) def current_time ( context , format ... _string ): timezone = context [ "timezone" ] return your_get_current_time_method ( timezone , format_string ) 最初の引数は context に しなければならない ... ことに注意してください。 takes_context オプションがどのように動くかについて、詳しくは inclusion tag を参照してください。 タグの名前を変更する必要がある場合は、カ ... ... mat_html() を使うことを強く推奨します。 テンプレートタグの中からコンテキストにアクセスしたい場合、タグを登録する際に takes_context 引数を使うことでできるようになります。 @register . simple_tag ( takes_context = True ) def current_time ( context , format ... _string ): timezone = context [ "timezone" ] return your_get_current_time_method ( timezone , format_string ) 最初の引数は context に しなければならない ... ことに注意してください。 takes_context オプションがどのように動くかについて、詳しくは inclusion tag を参照してください。 タグの名前を変更する必要がある場合は、カ ... ... mplateResponseMixin ) は、実際のオブジェクトを扱うときに、より柔軟なデフォルトを提供するためにこれをオーバーライドします。 ContextMixin Every built in view which needs context data, such as for rendering a template (including TemplateResponseMixin above ... ), should call get_context_data() passing any data they want to ensure is in there as keyword arguments. get_context_data() returns a dictionary; in ... its keyword arguments, but it is common to override this to add more members to the dictionary. You can also use the extra_context attribute. Django の一般的なクラスベースのビューを構築する ¶ Djangoのクラスベースのジェネリックビューが、個々の機能を提供す ... ... mplateResponseMixin ) は、実際のオブジェクトを扱うときに、より柔軟なデフォルトを提供するためにこれをオーバーライドします。 ContextMixin Every built in view which needs context data, such as for rendering a template (including TemplateResponseMixin above ... ), should call get_context_data() passing any data they want to ensure is in there as keyword arguments. get_context_data() returns a dictionary; in ... its keyword arguments, but it is common to override this to add more members to the dictionary. You can also use the extra_context attribute. Django の一般的なクラスベースのビューを構築する ¶ Djangoのクラスベースのジェネリックビューが、個々の機能を提供す ... ... チャート setup() dispatch() http_method_not_allowed() get_template_names() get_slug_field() get_queryset() get_object() get_context_object_name() get_context_data() get() render_to_response() 例 myapp/views.py : from django.utils import timezone from dja ... tail import DetailView from articles.models import Article class ArticleDetailView ( DetailView ): model = Article def get_context_data ( self , ** kwargs ): context = super () . get_context_data ( ** kwargs ) context [ "now" ] = timezone . now () retur ... n context 例 myapp/urls.py : from django.urls import path from article.views import ArticleDetailView urlpatterns = [ path ( "<slug: ... ... チャート setup() dispatch() http_method_not_allowed() get_template_names() get_slug_field() get_queryset() get_object() get_context_object_name() get_context_data() get() render_to_response() 例 myapp/views.py : from django.utils import timezone from dja ... tail import DetailView from articles.models import Article class ArticleDetailView ( DetailView ): model = Article def get_context_data ( self , ** kwargs ): context = super () . get_context_data ( ** kwargs ) context [ "now" ] = timezone . now () retur ... n context 例 myapp/urls.py : from django.urls import path from article.views import ArticleDetailView urlpatterns = [ path ( "<slug: ... 2026年10月08日