... jango.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 u ... ルト値: [ "get" , "post" , "put" , "patch" , "delete" , "head" , "options" , "trace" ] メソッド classmethod as_view ( ** initkwargs ) ¶ リクエストを受け取ってレスポンスを返す、呼び出し可能なビューを返します: response = MyView . as_view ()( request ) 返さ ... れたビューは、 view_class と view_initkwargs 属性を持っています。 リクエスト/レスポンスサイクル中にビューが呼び出されると、 setup() メソッドは HttpRequest をビューの r ... ... jango.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 u ... ルト値: [ "get" , "post" , "put" , "patch" , "delete" , "head" , "options" , "trace" ] メソッド classmethod as_view ( ** initkwargs ) ¶ リクエストを受け取ってレスポンスを返す、呼び出し可能なビューを返します: response = MyView . as_view ()( request ) 返さ ... れたビューは、 view_class と view_initkwargs 属性を持っています。 リクエスト/レスポンスサイクル中にビューが呼び出されると、 setup() メソッドは HttpRequest をビューの r ... ... 指定します(これがどういう意味かについては required セクションを参照してください)。 BooleanField ¶ class BooleanField ( ** kwargs ) [ソース] ¶ デフォルトのウィジェット: CheckboxInput 空の値: False 正規化後の値: Pythonの True または False になります。 フ ... めたい場合は、 BooleanField を作成する際に required=False を渡すことを忘れないでください。 CharField ¶ class CharField ( ** kwargs ) [ソース] ¶ デフォルトのウィジェット: TextInput 空の値: empty_value として与えたもの 正規化後の値: 文字列になります。 max ... 除されます。 empty_value ¶ 「空」を表すのに使用する値です。デフォルトは空の文字列です。 ChoiceField ¶ class ChoiceField ( ** kwargs ) [ソース] ¶ デフォルトのウィジェット: Select 空の値: '' (空の文字列) 正規化後の値: 文字列になります。 指定された値が選択肢 ... ... 指定します(これがどういう意味かについては required セクションを参照してください)。 BooleanField ¶ class BooleanField ( ** kwargs ) [ソース] ¶ デフォルトのウィジェット: CheckboxInput 空の値: False 正規化後の値: Pythonの True または False になります。 フ ... めたい場合は、 BooleanField を作成する際に required=False を渡すことを忘れないでください。 CharField ¶ class CharField ( ** kwargs ) [ソース] ¶ デフォルトのウィジェット: TextInput 空の値: empty_value として与えたもの 正規化後の値: 文字列になります。 max ... 除されます。 empty_value ¶ 「空」を表すのに使用する値です。デフォルトは空の文字列です。 ChoiceField ¶ class ChoiceField ( ** kwargs ) [ソース] ¶ デフォルトのウィジェット: Select 空の値: '' (空の文字列) 正規化後の値: 文字列になります。 指定された値が選択肢 ... ... 用します。 reverse ( viewname , urlconf = None , args = None , kwargs = None , current_app = None , * , query = None , fragment = None ) [ソース] ¶ viewname には URL パターン名 またはURLconf で ... ngo.urls import reverse def myview ( request ): return HttpResponseRedirect ( reverse ( "arch-summary" , args = [ 1945 ])) kwargs を args の代わりに渡すこともできます。例えば: >>> reverse ( "admin:app_list" , kwargs = { "app_label" : "auth" }) '/admin/ ... auth/' args と kwargs を同時に reverse() に渡すことはできません。 一致するものが見つからない場合、 reverse() は NoReverseMatch 例外を発生させます ... ... n , View ): """Records the current user's interest in an author.""" model = Author def post ( self , request , * args , ** kwargs ): if not request . user . is_authenticated : return HttpResponseForbidden () # Look up the author we're interested in. se ... = self . get_object () # Actually record interest somehow here! return HttpResponseRedirect ( reverse ( "author-detail" , kwargs = { "pk" : self . object . pk }) ) 実際には、リレーショナルデータベースではなく、キーバリューストアに関心事を記録したいと思 ... ctMixin , ListView ): paginate_by = 2 template_name = "books/publisher_detail.html" def get ( self , request , * args , ** kwargs ): self . object = self . get_object ( queryset = Publisher . objects . all ()) return super () . get ( request , * args , ... ... 用します。 reverse ( viewname , urlconf = None , args = None , kwargs = None , current_app = None , * , query = None , fragment = None ) [ソース] ¶ viewname には URL パターン名 またはURLconf で ... ngo.urls import reverse def myview ( request ): return HttpResponseRedirect ( reverse ( "arch-summary" , args = [ 1945 ])) kwargs を args の代わりに渡すこともできます。例えば: >>> reverse ( "admin:app_list" , kwargs = { "app_label" : "auth" }) '/admin/ ... auth/' args と kwargs を同時に reverse() に渡すことはできません。 一致するものが見つからない場合、 reverse() は NoReverseMatch 例外を発生させます ... ... n , View ): """Records the current user's interest in an author.""" model = Author def post ( self , request , * args , ** kwargs ): if not request . user . is_authenticated : return HttpResponseForbidden () # Look up the author we're interested in. se ... = self . get_object () # Actually record interest somehow here! return HttpResponseRedirect ( reverse ( "author-detail" , kwargs = { "pk" : self . object . pk }) ) 実際には、リレーショナルデータベースではなく、キーバリューストアに関心事を記録したいと思 ... ctMixin , ListView ): paginate_by = 2 template_name = "books/publisher_detail.html" def get ( self , request , * args , ** kwargs ): self . object = self . get_object ( queryset = Publisher . objects . all ()) return super () . get ( request , * args , ... ... のスタブチェック関数です。 from django.core.checks import Error , register @register () def example_check ( app_configs , ** kwargs ): errors = [] # ... your check logic here if check_failed : errors . append ( Error ( "an error" , hint = "A hint." , obj ... あるデータベースエイリアスのリストです。 databases が None の場合、チェックはどのデータベース接続も使用してはいけません。 **kwargs 引数は将来の拡張のために必要です。 メッセージ ¶ 関数は、メッセージのリストを返さなければなりません。チェックの結果、問題が ... 出します: from django.core.checks import register , Tags @register ( Tags . compatibility ) def my_check ( app_configs , ** kwargs ): # ... perform compatibility checks and collect errors return errors 以下のように、本番用の設定ファイルにのみ関係する「デ ... ... のスタブチェック関数です。 from django.core.checks import Error , register @register () def example_check ( app_configs , ** kwargs ): errors = [] # ... your check logic here if check_failed : errors . append ( Error ( "an error" , hint = "A hint." , obj ... あるデータベースエイリアスのリストです。 databases が None の場合、チェックはどのデータベース接続も使用してはいけません。 **kwargs 引数は将来の拡張のために必要です。 メッセージ ¶ 関数は、メッセージのリストを返さなければなりません。チェックの結果、問題が ... 出します: from django.core.checks import register , Tags @register ( Tags . compatibility ) def my_check ( app_configs , ** kwargs ): # ... perform compatibility checks and collect errors return errors 以下のように、本番用の設定ファイルにのみ関係する「デ ... 2026年10月08日