... を使用します: from django.db import models class Client ( models . Model ): REGULAR = "R" GOLD = "G" PLATINUM = "P" ACCOUNT_TYPE_CHOICES = { REGULAR : "Regular" , GOLD : "Gold" , PLATINUM : "Platinum" , } name = models . CharField ( max_length = 50 ) ... registered_on = models . DateField () account_type = models . CharField ( max_length = 1 , choices = ACCOUNT_TYPE_CHOICES , default = REGULAR , ) When ¶ class When ( conditi ... import F , Q , When >>> # String arguments refer to fields; the following two examples are equivalent: >>> When ( account_type = Client . GOLD , then = "name" ) >>> When ( account_type = Client . GOLD , then = F ( "name" )) >>> # You can use field l ... ... を使用します: from django.db import models class Client ( models . Model ): REGULAR = "R" GOLD = "G" PLATINUM = "P" ACCOUNT_TYPE_CHOICES = { REGULAR : "Regular" , GOLD : "Gold" , PLATINUM : "Platinum" , } name = models . CharField ( max_length = 50 ) ... registered_on = models . DateField () account_type = models . CharField ( max_length = 1 , choices = ACCOUNT_TYPE_CHOICES , default = REGULAR , ) When ¶ class When ( conditi ... import F , Q , When >>> # String arguments refer to fields; the following two examples are equivalent: >>> When ( account_type = Client . GOLD , then = "name" ) >>> When ( account_type = Client . GOLD , then = F ( "name" )) >>> # You can use field l ... ... する GET/POST ディクショナリからデータを取り出します。 Built-in widgets によって作られる HTML は、 <!DOCTYPE html> を対象とした HTML5 シンタックスを使います。たとえば、XHTML スタイルである checked='checked' よりも、 checked といった ... グが適用され、CSS クラスや追加の属性はありません。 >>> f = CommentForm ( auto_id = False ) >>> print ( f ) <div>Name:<input type="text" name="name" required></div> <div>Url:<input type="url" name="url" required></div> <div>Comment:<input type="text" n ... 素を、名前用のウィジェットには特別な CSS クラスを指定したいかもしれません。また、HTML5 の異なる入力タイプを使用するために、 'type' 属性を指定することも可能です。これを行うには、ウィジェットを作成する際に Widget.attrs 引数を使用します。 class CommentFor ... ... する GET/POST ディクショナリからデータを取り出します。 Built-in widgets によって作られる HTML は、 <!DOCTYPE html> を対象とした HTML5 シンタックスを使います。たとえば、XHTML スタイルである checked='checked' よりも、 checked といった ... グが適用され、CSS クラスや追加の属性はありません。 >>> f = CommentForm ( auto_id = False ) >>> print ( f ) <div>Name:<input type="text" name="name" required></div> <div>Url:<input type="url" name="url" required></div> <div>Comment:<input type="text" n ... 素を、名前用のウィジェットには特別な CSS クラスを指定したいかもしれません。また、HTML5 の異なる入力タイプを使用するために、 'type' 属性を指定することも可能です。これを行うには、ウィジェットを作成する際に Widget.attrs 引数を使用します。 class CommentFor ... ... inspectdb コマンドラインオプション loaddata コマンドラインオプション migrate コマンドラインオプション remove_stale_contenttypes コマンドラインオプション showmigrations コマンドラインオプション sqlflush コマンドラインオプション sqlmigrate コマンドライ ... コマンドラインオプション --include-partitions inspectdb コマンドラインオプション --include-stale-apps remove_stale_contenttypes コマンドラインオプション --include-views inspectdb コマンドラインオプション --indent dumpdata コマンドラインオプション -- ... メソッド) app_directories.Loader (django.template.loaders のクラス) app_index_template (AdminSite の属性) app_label (ContentType の属性) (Options の属性) app_name (ResolverMatch の属性) app_names (ResolverMatch の属性) AppCommand (django.core.manageme ... ... inspectdb コマンドラインオプション loaddata コマンドラインオプション migrate コマンドラインオプション remove_stale_contenttypes コマンドラインオプション showmigrations コマンドラインオプション sqlflush コマンドラインオプション sqlmigrate コマンドライ ... コマンドラインオプション --include-partitions inspectdb コマンドラインオプション --include-stale-apps remove_stale_contenttypes コマンドラインオプション --include-views inspectdb コマンドラインオプション --indent dumpdata コマンドラインオプション -- ... メソッド) app_directories.Loader (django.template.loaders のクラス) app_index_template (AdminSite の属性) app_label (ContentType の属性) (Options の属性) app_name (ResolverMatch の属性) app_names (ResolverMatch の属性) AppCommand (django.core.manageme ... ... arField () ... >>> f = CommentForm ( initial = { "name" : "instance" }, auto_id = False ) >>> print ( f ) <div>Name:<input type="text" name="name" value="instance" required></div> <div>Url:<input type="url" name="url" required></div> <div>Comment:<in ... put type="text" name="comment" required></div> Form. get_initial_for_field ( field , field_name ) ¶ フォームフィールドの初期データを ... の表示方法を変更できます。 >>> f . as_div () . split ( "</div>" )[ 0 ] '<div><label for="id_subject">Subject:</label><input type="text" name="subject" maxlength="100" required id="id_subject">' >>> f [ "subject" ] . label = "Topic" >>> f . as_div () . ... ... arField () ... >>> f = CommentForm ( initial = { "name" : "instance" }, auto_id = False ) >>> print ( f ) <div>Name:<input type="text" name="name" value="instance" required></div> <div>Url:<input type="url" name="url" required></div> <div>Comment:<in ... put type="text" name="comment" required></div> Form. get_initial_for_field ( field , field_name ) ¶ フォームフィールドの初期データを ... の表示方法を変更できます。 >>> f . as_div () . split ( "</div>" )[ 0 ] '<div><label for="id_subject">Subject:</label><input type="text" name="subject" maxlength="100" required id="id_subject">' >>> f [ "subject" ] . label = "Topic" >>> f . as_div () . ... ... ArticleFormSet () >>> for form in formset : ... print ( form ) ... <div><label for="id_form-0-title">Title:</label><input type="text" name="form-0-title" id="id_form-0-title"></div> <div><label for="id_form-0-pub_date">Pub date:</label><input type=" ... ... } ... ] ... ) >>> for form in formset : ... print ( form ) ... <div><label for="id_form-0-title">Title:</label><input type="text" name="form-0-title" value="Django is now open source" id="id_form-0-title"></div> <div><label for="id_form-0-pub_da ... te">Pub date:</label><input type="text" name="form-0-pub_date" value="2023-02-11" id="id_form-0-pub_date"></div> <div><label for="id_form-1-title">Title:</ ... ... ArticleFormSet () >>> for form in formset : ... print ( form ) ... <div><label for="id_form-0-title">Title:</label><input type="text" name="form-0-title" id="id_form-0-title"></div> <div><label for="id_form-0-pub_date">Pub date:</label><input type=" ... ... } ... ] ... ) >>> for form in formset : ... print ( form ) ... <div><label for="id_form-0-title">Title:</label><input type="text" name="form-0-title" value="Django is now open source" id="id_form-0-title"></div> <div><label for="id_form-0-pub_da ... te">Pub date:</label><input type="text" name="form-0-pub_date" value="2023-02-11" id="id_form-0-pub_date"></div> <div><label for="id_form-1-title">Title:</ ... 2026年10月08日