... le は一つの Reporter オブジェクトしか持つことができません: from django.db import models class Reporter ( models . Model ): first_name = models . CharField ( max_length = 30 ) last_name = models . CharField ( max_length = 30 ) email = models . EmailFie ... ld () def __str__ ( self ): return f " { self . first_name } { self . last_name } " class Article ( models . Model ): headline = models . CharField ( max_length = 100 ) pub_dat ... = [ "headline" ] 以下は、Python API の機能を使って実行できる操作の例です。 複数の Reporter を作成する: >>> r = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> r . save () >>> r2 = Reporter ( first_name = "Paul" ... ... le は一つの Reporter オブジェクトしか持つことができません: from django.db import models class Reporter ( models . Model ): first_name = models . CharField ( max_length = 30 ) last_name = models . CharField ( max_length = 30 ) email = models . EmailFie ... ld () def __str__ ( self ): return f " { self . first_name } { self . last_name } " class Article ( models . Model ): headline = models . CharField ( max_length = 100 ) pub_dat ... = [ "headline" ] 以下は、Python API の機能を使って実行できる操作の例です。 複数の Reporter を作成する: >>> r = Reporter ( first_name = "John" , last_name = "Smith" , email = "john@example.com" ) >>> r . save () >>> r2 = Reporter ( first_name = "Paul" ... ... ます: fields フィールドセット内に表示するフィールド名のリストまたはタプルです。このキーは必須です。 実装例: { "fields" : [ "first_name" , "last_name" , "address" , "city" , "state" ], } fields オプションと同様に、複数のフィールドを 1 行に表示するにはタ ... プルでこれらのフィールドを囲んでください。この例では、 first_name と last_name フィールドが 1 つの行に表示されます。 { "fields" : [( "first_name" , "last_name" ), "address" , "city" , ... ンジリストページでどのフィールドを表示するかコントロールするために、 list_display をセットします。 実装例: list_display = [ "first_name" , "last_name" ] list_display をセットしない場合、admin サイトは各オブジェクトの __str__() 表現を表示する単一の列を表 ... ... ます: fields フィールドセット内に表示するフィールド名のリストまたはタプルです。このキーは必須です。 実装例: { "fields" : [ "first_name" , "last_name" , "address" , "city" , "state" ], } fields オプションと同様に、複数のフィールドを 1 行に表示するにはタ ... プルでこれらのフィールドを囲んでください。この例では、 first_name と last_name フィールドが 1 つの行に表示されます。 { "fields" : [( "first_name" , "last_name" ), "address" , "city" , ... ンジリストページでどのフィールドを表示するかコントロールするために、 list_display をセットします。 実装例: list_display = [ "first_name" , "last_name" ] list_display をセットしない場合、admin サイトは各オブジェクトの __str__() 表現を表示する単一の列を表 ... ... ロジックです。以下はその例です: >>> from django.template import Context , Template >>> t = Template ( "My name is {{ person.first_name }}." ) >>> d = { "person" : { "first_name" : "Joe" , "last_name" : "Johnson" }} >>> t . render ( Context ( d )) "My n ... ame is Joe." >>> class PersonClass : ... pass ... >>> p = PersonClass () >>> p . first_name = "Ron" >>> p . last_name = "Nasty" >>> t . render ( Context ({ "person" : p })) "My name is Ron." >>> t = Template ( ... "The first stooge in the list is {{ stooges.0 }}." ) >>> c = Context ({ "stooges" : [ "Larry" , "Curly" , "Moe" ]}) >>> t . render ( ... ... れた値がデータの部分集合であるものです。これは SQL 演算子 @> を使用します。たとえば、: >>> Post . objects . create ( name = "First post" , tags = [ "thoughts" , "django" ]) >>> Post . objects . create ( name = "Second post" , tags = [ "thoughts" ]) >>> ... post" , tags = [ "tutorial" , "django" ]) >>> Post . objects . filter ( tags__contains = [ "thoughts" ]) <QuerySet [<Post: First post>, <Post: Second post>]> >>> Post . objects . filter ( tags__contains = [ "django" ]) <QuerySet [<Post: First post>, < ... Post: Third post>]> >>> Post . objects . filter ( tags__contains = [ "django" , "thoughts" ]) <QuerySet [<Post: First post>]> contained_by ¶ これは contains ルックアップの逆です。返されるオブジェクトは、データが渡された値の部分集合であるもの ... ... れた値がデータの部分集合であるものです。これは SQL 演算子 @> を使用します。たとえば、: >>> Post . objects . create ( name = "First post" , tags = [ "thoughts" , "django" ]) >>> Post . objects . create ( name = "Second post" , tags = [ "thoughts" ]) >>> ... post" , tags = [ "tutorial" , "django" ]) >>> Post . objects . filter ( tags__contains = [ "thoughts" ]) <QuerySet [<Post: First post>, <Post: Second post>]> >>> Post . objects . filter ( tags__contains = [ "django" ]) <QuerySet [<Post: First post>, < ... Post: Third post>]> >>> Post . objects . filter ( tags__contains = [ "django" , "thoughts" ]) <QuerySet [<Post: First post>]> contained_by ¶ これは contains ルックアップの逆です。返されるオブジェクトは、データが渡された値の部分集合であるもの ... ... ロジックです。以下はその例です: >>> from django.template import Context , Template >>> t = Template ( "My name is {{ person.first_name }}." ) >>> d = { "person" : { "first_name" : "Joe" , "last_name" : "Johnson" }} >>> t . render ( Context ( d )) "My n ... ame is Joe." >>> class PersonClass : ... pass ... >>> p = PersonClass () >>> p . first_name = "Ron" >>> p . last_name = "Nasty" >>> t . render ( Context ({ "person" : p })) "My name is Ron." >>> t = Template ( ... "The first stooge in the list is {{ stooges.0 }}." ) >>> c = Context ({ "stooges" : [ "Larry" , "Curly" , "Moe" ]}) >>> t . render ( ... ... allows the reviewer to focus on the change itself, and it can also help to reduce the number of CI runs. To use the tool, first install pre-commit and then the git hooks: / $ python -m pip install pre-commit $ pre-commit install ...\> py -m pip i ... nstall pre-commit ...\> pre-commit install On the first commit pre-commit will install the hooks, these are installed in their own environments and will take a short while to ins ... tall on the first run. Subsequent checks will be significantly faster. If an error is found an appropriate error message will be displayed. ... ... ped_object [ "model" ] def end_object ( self , obj ): dumped_object_str , model = self . get_dump_object ( obj ) if self . first : fields = [ field . name for field in apps . get_model ( model ) . _meta . fields ] header = "," . join ( fields ) self . ... ルキーのデシリアライズ ¶ 次の2つのモデルを考えてみてください。 from django.db import models class Person ( models . Model ): first_name = models . CharField ( max_length = 100 ) last_name = models . CharField ( max_length = 100 ) birthdate = models . Da ... teField () class Meta : constraints = [ models . UniqueConstraint ( fields = [ "first_name" , "last_name" ], name = "unique_first_last_name" , ), ] class Book ( models . Model ): name = models . CharField ( m ... 2026年10月08日