... なこともあります。たとえば、使用するテンプレートを変更したり、追加データをコンテキストに追加したりしたくなるかもしれません。 TemplateResponse はそのための方法を提供します。基本的な HttpResponse オブジェクトとは異なり、 TemplateResponse オブジェクトはレスポンスを計 ... ートとコンテキストの詳細を保持します。レスポンスの最終的な出力は、レスポンス処理の後半で必要になるまで計算されません。 SimpleTemplateResponse オブジェクト ¶ class SimpleTemplateResponse [ソース] ¶ 属性 ¶ SimpleTemplateResponse. template_name ¶ The name of the temp ... urned by get_template() ), the name of a template, or a list of template names. 例: ['foo.html', 'path/to/bar.html'] SimpleTemplateResponse. context_data ¶ テンプレートをレンダリングするときに使用するコンテキストデータ。 これは dict でなければなりません。 例: {' ... ... なこともあります。たとえば、使用するテンプレートを変更したり、追加データをコンテキストに追加したりしたくなるかもしれません。 TemplateResponse はそのための方法を提供します。基本的な HttpResponse オブジェクトとは異なり、 TemplateResponse オブジェクトはレスポンスを計 ... ートとコンテキストの詳細を保持します。レスポンスの最終的な出力は、レスポンス処理の後半で必要になるまで計算されません。 SimpleTemplateResponse オブジェクト ¶ class SimpleTemplateResponse [ソース] ¶ 属性 ¶ SimpleTemplateResponse. template_name ¶ The name of the temp ... urned by get_template() ), the name of a template, or a list of template names. 例: ['foo.html', 'path/to/bar.html'] SimpleTemplateResponse. context_data ¶ テンプレートをレンダリングするときに使用するコンテキストデータ。 これは dict でなければなりません。 例: {' ... ... を設定してください。より詳しい情報については、 テンプレートコンテキストのレンダリング に関するドキュメントを読んでください。 TemplateResponseMixin ¶ class django.views.generic.base. TemplateResponseMixin ¶ 適切なコンテキストを指定して TemplateResponse を構築するメ ... 全てのエンジンでテンプレートを検索します。 response_class ¶ render_to_response メソッドが返す response クラス。 デフォルトは TemplateResponse です。 TemplateResponse インスタンスのテンプレートとコンテキストは後で変更できます (たとえば template response ミドルウェア ... で変更できます)。 カスタムテンプレートの読み込みやカスタムコンテキストオブジェクトのインスタンス化が必要な場合は、 TemplateResponse サブクラスを作成して response_class に代入してください。 content_type ¶ レスポンスに使用するコンテンツタイプ。 content_typ ... ... を設定してください。より詳しい情報については、 テンプレートコンテキストのレンダリング に関するドキュメントを読んでください。 TemplateResponseMixin ¶ class django.views.generic.base. TemplateResponseMixin ¶ 適切なコンテキストを指定して TemplateResponse を構築するメ ... 全てのエンジンでテンプレートを検索します。 response_class ¶ render_to_response メソッドが返す response クラス。 デフォルトは TemplateResponse です。 TemplateResponse インスタンスのテンプレートとコンテキストは後で変更できます (たとえば template response ミドルウェア ... で変更できます)。 カスタムテンプレートの読み込みやカスタムコンテキストオブジェクトのインスタンス化が必要な場合は、 TemplateResponse サブクラスを作成して response_class に代入してください。 content_type ¶ レスポンスに使用するコンテンツタイプ。 content_typ ... ... 況もあります; POST ではテンプレートをレンダリングするだけで、 GET のときはまったく異なる処理がしたいときなどです。この場合、 TemplateResponse を直接使えますが、コードが重複する結果となってしまいます。 この理由から、Django は個別の機能を提供する多くの mixin を用意し ... ています。たとえば、テンプレートのレンダリングは TemplateResponseMixin でカプセル化されています。Django のリファレンスドキュメントには すべてのミックスインの完全なドキュメント があります。 ... スイン (mixin) が用意されており、クラスベースビュー内のテンプレートを扱うインターフェースに一貫性を保ちやすくなっています。 TemplateResponseMixin Every built in view which returns a TemplateResponse will call the render_to_response() method that TemplateResponseM ... ... a single with block. The load tag now accepts a from argument, allowing you to load a single tag or filter from a library. TemplateResponse ¶ It can sometimes be beneficial to allow decorators or middleware to modify a response after it has been constructed by t ... dify the content of a basic HttpResponse after it has been constructed. To overcome this limitation, Django 1.3 adds a new TemplateResponse class. Unlike basic HttpResponse objects, TemplateResponse objects retain the details of the template and context that was ... response is not computed until it is needed, later in the response process. For more details, see the documentation on the TemplateResponse class. Caching changes ¶ Django 1.3 sees the introduction of several improvements to the Django's caching infrastructure. ... ... 況もあります; POST ではテンプレートをレンダリングするだけで、 GET のときはまったく異なる処理がしたいときなどです。この場合、 TemplateResponse を直接使えますが、コードが重複する結果となってしまいます。 この理由から、Django は個別の機能を提供する多くの mixin を用意し ... ています。たとえば、テンプレートのレンダリングは TemplateResponseMixin でカプセル化されています。Django のリファレンスドキュメントには すべてのミックスインの完全なドキュメント があります。 ... スイン (mixin) が用意されており、クラスベースビュー内のテンプレートを扱うインターフェースに一貫性を保ちやすくなっています。 TemplateResponseMixin Every built in view which returns a TemplateResponse will call the render_to_response() method that TemplateResponseM ... ... a single with block. The load tag now accepts a from argument, allowing you to load a single tag or filter from a library. TemplateResponse ¶ It can sometimes be beneficial to allow decorators or middleware to modify a response after it has been constructed by t ... dify the content of a basic HttpResponse after it has been constructed. To overcome this limitation, Django 1.3 adds a new TemplateResponse class. Unlike basic HttpResponse objects, TemplateResponse objects retain the details of the template and context that was ... response is not computed until it is needed, later in the response process. For more details, see the documentation on the TemplateResponse class. Caching changes ¶ Django 1.3 sees the introduction of several improvements to the Django's caching infrastructure. ... ... k, that means that dumpdata output will now contain the SRID value of geometry objects. Priority of context processors for TemplateResponse brought in line with render ¶ The TemplateResponse constructor is designed to be a drop-in replacement for the render() fu ... nction. However, it had a slight incompatibility, in that for TemplateResponse , context data from the passed in context dictionary could be shadowed by context data returned from context processors, w ... lobally defined context processors to be overridden locally in the view. If you were relying on the fact context data in a TemplateResponse could be overridden using a context processor, you will need to change your code. Overriding setUpClass / tearDownClass in ... ... k, that means that dumpdata output will now contain the SRID value of geometry objects. Priority of context processors for TemplateResponse brought in line with render ¶ The TemplateResponse constructor is designed to be a drop-in replacement for the render() fu ... nction. However, it had a slight incompatibility, in that for TemplateResponse , context data from the passed in context dictionary could be shadowed by context data returned from context processors, w ... lobally defined context processors to be overridden locally in the view. If you were relying on the fact context data in a TemplateResponse could be overridden using a context processor, you will need to change your code. Overriding setUpClass / tearDownClass in ... 2026年10月08日