... データベースの1つのカラムに対して1つの用語を検索することです。たとえば: >>> Entry . objects . filter ( body_text__search = "Cheese" ) <QuerySet [<Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>]> これにより、データベース内の body_text フィールド ... から to_tsvector が作成され、検索語 'Cheese' から plainto_tsquery が作成されます。両方ともデフォルトのデータベース検索設定を使用しています。結果は、クエリとベクトルを ... r >>> Entry . objects . annotate ( ... search = SearchVector ( "body_text" , "blog__tagline" ), ... ) . filter ( search = "Cheese" ) <QuerySet [<Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>]> SearchVector への引数は、任意の Expression または ... ... データベースの1つのカラムに対して1つの用語を検索することです。たとえば: >>> Entry . objects . filter ( body_text__search = "Cheese" ) <QuerySet [<Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>]> これにより、データベース内の body_text フィールド ... から to_tsvector が作成され、検索語 'Cheese' から plainto_tsquery が作成されます。両方ともデフォルトのデータベース検索設定を使用しています。結果は、クエリとベクトルを ... r >>> Entry . objects . annotate ( ... search = SearchVector ( "body_text" , "blog__tagline" ), ... ) . filter ( search = "Cheese" ) <QuerySet [<Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>]> SearchVector への引数は、任意の Expression または ... ... があります。 django.contrib.postgres モジュールは、これらのクエリを作成するためのヘルパーをいくつか提供しています。例えば、"cheese" に言及している全てのブログエントリを選択するクエリがあります: >>> Entry . objects . filter ( body_text__search = "cheese" ... ) [<Entry: Cheese on Toast recipes>, <Entry: Pizza recipes>] また、フィールドの組み合わせやリレーション先モデルでフィルタをかけることもできま ... : >>> Entry . objects . annotate ( ... search = SearchVector ( "blog__tagline" , "body_text" ), ... ) . filter ( search = "cheese" ) [ <Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>, <Entry: Dairy farming in Argentina>, ] 詳細は contrib.postg ... ... があります。 django.contrib.postgres モジュールは、これらのクエリを作成するためのヘルパーをいくつか提供しています。例えば、"cheese" に言及している全てのブログエントリを選択するクエリがあります: >>> Entry . objects . filter ( body_text__search = "cheese" ... ) [<Entry: Cheese on Toast recipes>, <Entry: Pizza recipes>] また、フィールドの組み合わせやリレーション先モデルでフィルタをかけることもできま ... : >>> Entry . objects . annotate ( ... search = SearchVector ( "blog__tagline" , "body_text" ), ... ) . filter ( search = "cheese" ) [ <Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>, <Entry: Dairy farming in Argentina>, ] 詳細は contrib.postg ... ... リメントの値が計算され、オブジェクトの属性として保存されます: >>> b2 = Blog ( name = "Cheddar Talk" , tagline = "Thoughts on cheese." ) >>> b2 . id # Returns None, because b2 doesn't have an ID yet. >>> b2 . save () >>> b2 . id # Returns the ID of your n ... に頼るのではなく、保存前に明示的に定義してください: >>> b3 = Blog ( id = 3 , name = "Cheddar Talk" , tagline = "Thoughts on cheese." ) >>> b3 . id # Returns 3. >>> b3 . save () >>> b3 . id # Returns 3. 自動主キー値を手動で割り当てる場合は、既に存在する主 ... と、この例はデータベースの以前のレコードを上書きします: b4 = Blog ( id = 3 , name = "Not Cheddar" , tagline = "Anything but cheese." ) b4 . save () # Overrides the previous blog with ID=3! このようなことが起こる理由については、後述の How Django knows to ... ... リメントの値が計算され、オブジェクトの属性として保存されます: >>> b2 = Blog ( name = "Cheddar Talk" , tagline = "Thoughts on cheese." ) >>> b2 . id # Returns None, because b2 doesn't have an ID yet. >>> b2 . save () >>> b2 . id # Returns the ID of your n ... に頼るのではなく、保存前に明示的に定義してください: >>> b3 = Blog ( id = 3 , name = "Cheddar Talk" , tagline = "Thoughts on cheese." ) >>> b3 . id # Returns 3. >>> b3 . save () >>> b3 . id # Returns 3. 自動主キー値を手動で割り当てる場合は、既に存在する主 ... と、この例はデータベースの以前のレコードを上書きします: b4 = Blog ( id = 3 , name = "Not Cheddar" , tagline = "Anything but cheese." ) b4 . save () # Overrides the previous blog with ID=3! このようなことが起こる理由については、後述の How Django knows to ... ... て、以下でそれらを取得できます)。 >>> from blog.models import Blog , Entry >>> entry = Entry . objects . get ( pk = 1 ) >>> cheese_blog = Blog . objects . get ( name = "Cheddar Talk" ) >>> entry . blog = cheese_blog >>> entry . save () ManyToManyField を ... ... て、以下でそれらを取得できます)。 >>> from blog.models import Blog , Entry >>> entry = Entry . objects . get ( pk = 1 ) >>> cheese_blog = Blog . objects . get ( name = "Cheddar Talk" ) >>> entry . blog = cheese_blog >>> entry . save () ManyToManyField を ... 2026年10月08日