... エラルキーがわかりやすく紹介されています。 シンプルなジェネリックビュー ¶ View ¶ class View ¶ 属性 (とオプションのアクセサ): http_method_names メソッド as_view() dispatch() head() 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_vi ... ew() dispatch() get() get_context_data() head() http_method_not_allowed() render_to_response() setup() RedirectView ¶ class RedirectView ¶ 属性 (とオプションのアクセサ): http_ ... ... エラルキーがわかりやすく紹介されています。 シンプルなジェネリックビュー ¶ View ¶ class View ¶ 属性 (とオプションのアクセサ): http_method_names メソッド as_view() dispatch() head() 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_vi ... ew() dispatch() get() get_context_data() head() http_method_not_allowed() render_to_response() setup() RedirectView ¶ class RedirectView ¶ 属性 (とオプションのアクセサ): http_ ... ... 。 あるページがリクエストされたとき、Django はリクエストに関するメタデータを含んだ HttpRequest オブジェクトを生成します。それから Django は HttpRequest をビュー関数の最初の関数として渡し、適切なビューを読み込み ... ます。あらゆるビューは HttpResponse オブジェクトを返す必要があります。 このドキュメントでは、 HttpRequest と HttpResponse オブジェクトの API を説明して ... います。これは django.http モジュールにて定義されています。 HttpRequest オブジェクト ¶ class HttpRequest [ソース] ¶ 属性 ¶ 特に記載がない限り、全ての ... ... 。 あるページがリクエストされたとき、Django はリクエストに関するメタデータを含んだ HttpRequest オブジェクトを生成します。それから Django は HttpRequest をビュー関数の最初の関数として渡し、適切なビューを読み込み ... ます。あらゆるビューは HttpResponse オブジェクトを返す必要があります。 このドキュメントでは、 HttpRequest と HttpResponse オブジェクトの API を説明して ... います。これは django.http モジュールにて定義されています。 HttpRequest オブジェクト ¶ class HttpRequest [ソース] ¶ 属性 ¶ 特に記載がない限り、全ての ... ... -proxy connecting via HTTPS ¶ When deployed behind a reverse-proxy connecting to Django via HTTPS, django.http.HttpRequest.scheme would incorrectly d ... etect client requests made via HTTP as using HTTPS. This entails incorrect results for is_secure() , and build_absolute_uri() , and that HTTP requests would n ... ot be redirected to HTTPS in accordance with SECURE_SSL_REDIRECT . HttpRequest.scheme now respects SECURE_PROXY_SSL_HEADER , if it is configured, a ... ... xy connecting via HTTPS ¶ When deployed behind a reverse-proxy connecting to Django via HTTPS, django.http.HttpRequest.scheme would incorrectly d ... etect client requests made via HTTP as using HTTPS. This entails incorrect results for is_secure() , and build_absolute_uri() , and that HTTP requests would n ... ot be redirected to HTTPS in accordance with SECURE_SSL_REDIRECT . HttpRequest.scheme now respects SECURE_PROXY_SSL_HEADER , if it is configured, a ... ... ジェネリックビューではないので、 django.views からインポートすることもできます。 メソッドのフローチャート setup() dispatch() http_method_not_allowed() options() Example views.py : from django.http import HttpResponse from django.views import View class ... MyView ( View ): def get ( self , request , * args , ** kwargs ): return HttpResponse ( "Hello, World!" ) Example urls.py : from django.urls import path from myapp.views import MyView urlpatterns = [ ... path ( "mine/" , MyView . as_view (), name = "my-view" ), ] 属性 http_method_names ¶ このビューが受け入れる HTTP メソッドの名称のリストです。 デフォルト値: [ "get" , "post" , "put" , "patch" , ... ... ジェネリックビューではないので、 django.views からインポートすることもできます。 メソッドのフローチャート setup() dispatch() http_method_not_allowed() options() Example views.py : from django.http import HttpResponse from django.views import View class ... MyView ( View ): def get ( self , request , * args , ** kwargs ): return HttpResponse ( "Hello, World!" ) Example urls.py : from django.urls import path from myapp.views import MyView urlpatterns = [ ... path ( "mine/" , MyView . as_view (), name = "my-view" ), ] 属性 http_method_names ¶ このビューが受け入れる HTTP メソッドの名称のリストです。 デフォルト値: [ "get" , "post" , "put" , "patch" , ... ... イルにビューを記述します。 シンプルなビュー ¶ 以下は、HTML ドキュメントとして、現在の日付と時刻を返すビューです: from django.http import HttpResponse import datetime def current_datetime ( request ): now = datetime . datetime . now () html = '<html lan ... g="en"><body>It is now %s .</body></html>' % now return HttpResponse ( html ) 1 行ずつコードを見ていきましょう: 最初に、Python の datetime ライブラリ とともに、クラス HttpResponse を ... django.http モジュールからインポートします。 次に、 current_datetime という関数を定義します。これがビュー関数です。それぞれのビュー関数 ... ... -proxy connecting via HTTPS ¶ When deployed behind a reverse-proxy connecting to Django via HTTPS, django.http.HttpRequest.scheme would incorrectly d ... etect client requests made via HTTP as using HTTPS. This entails incorrect results for is_secure() , and build_absolute_uri() , and that HTTP requests would n ... ot be redirected to HTTPS in accordance with SECURE_SSL_REDIRECT . HttpRequest.scheme now respects SECURE_PROXY_SSL_HEADER , if it is configured, a ... 2026年10月08日