... 、次のように記述します: CheckConstraint ( condition = Q ( age__gte = 18 ) | Q ( age__isnull = True ), name = "age_gte_18" ) UniqueConstraint ¶ class UniqueConstraint ( * expressions , fields = () , name , condition = None , deferrable = None , include = ... classes = () , nulls_distinct = None , violation_error_code = None , violation_error_message = None ) [ソース] ¶ Creates a uniqueness guarantee in the database, enforced by either a unique constraint or a unique index depending on the options used. Con ... straint vs. index implementation Setting only UniqueConstraint.fields creates a true database constraint ( ADD CONSTRAINT ... UNIQUE ). Specifying any of UniqueConstraint.expr ... ... 、次のように記述します: CheckConstraint ( condition = Q ( age__gte = 18 ) | Q ( age__isnull = True ), name = "age_gte_18" ) UniqueConstraint ¶ class UniqueConstraint ( * expressions , fields = () , name , condition = None , deferrable = None , include = ... classes = () , nulls_distinct = None , violation_error_code = None , violation_error_message = None ) [ソース] ¶ Creates a uniqueness guarantee in the database, enforced by either a unique constraint or a unique index depending on the options used. Con ... straint vs. index implementation Setting only UniqueConstraint.fields creates a true database constraint ( ADD CONSTRAINT ... UNIQUE ). Specifying any of UniqueConstraint.expr ... ... 0 ). Fixed a regression in 1.8.8 causing incorrect index handling in migrations on PostgreSQL when adding db_index=True or unique=True to a CharField or TextField that already had the other specified, or when removing one of them from a field that had ... both, or when adding unique=True to a field already listed in unique_together ( #26034 ). Fixed a crash when using an __in lookup inside a Case expres ... 前のトピックへ Django 1.8.10 リリースノート 次のトピックへ Django 1.8.8 リリースノート 関連キーワード Fixed regression crash unique using caused admin translations incorrect index adding already copy リリースノート February fixes several bugs バグ 修正 u ... ... が NULL と空文字列の 2 通りになります。多くの場合、「データなし」を表す値が 2 つあるのは冗長です。例外として、 CharField に unique=True と blank=True の両方を設定する場合があります。この状況では、空文字列のオブジェクトを複数保存する際に一意制約違反を避け ... 簡単にアクセスできるようになっています。 警告 これらのプロパティ名をメンバ名として使用することはできません。 The use of enum.unique() is enforced to ensure that values cannot be defined multiple times. This is unlikely to be expected in choices for a fie ... メッセージにマッチするキーを持つ辞書を渡してください。 エラーメッセージのキーには null , blank , invalid , invalid_choice , unique , unique_for_date があります。以下の Field types セクションで説明する各フィールドには、追加のエラーメッセージキーが指定され ... ... が NULL と空文字列の 2 通りになります。多くの場合、「データなし」を表す値が 2 つあるのは冗長です。例外として、 CharField に unique=True と blank=True の両方を設定する場合があります。この状況では、空文字列のオブジェクトを複数保存する際に一意制約違反を避け ... 簡単にアクセスできるようになっています。 警告 これらのプロパティ名をメンバ名として使用することはできません。 The use of enum.unique() is enforced to ensure that values cannot be defined multiple times. This is unlikely to be expected in choices for a fie ... メッセージにマッチするキーを持つ辞書を渡してください。 エラーメッセージのキーには null , blank , invalid , invalid_choice , unique , unique_for_date があります。以下の Field types セクションで説明する各フィールドには、追加のエラーメッセージキーが指定され ... ... 0 ). Fixed a regression in 1.8.8 causing incorrect index handling in migrations on PostgreSQL when adding db_index=True or unique=True to a CharField or TextField that already had the other specified, or when removing one of them from a field that had ... both, or when adding unique=True to a field already listed in unique_together ( #26034 ). Fixed a crash when using an __in lookup inside a Case expres ... Django 1.8.10 リリースノート 次のトピックへ Django 1.8.8 リリースノート 関連キーワード Fixed regression True Django crash unique using caused admin translations incorrect index adding already field copy リリースノート February fixes several 関連するペ ... ... baseSchemaEditor. remove_constraint ( model , constraint ) [ソース] ¶ model のテーブルから constraint を削除します。 alter_unique_together() ¶ BaseDatabaseSchemaEditor. alter_unique_together ( model , old_unique_together , new_unique_together ) [ソース ... ] ¶ モデルの unique_together 値を変更します。これにより、新しい値に一致するまで、モデルのテーブルからユニーク制約が追加または削除されます。 al ... l , field ) [ソース] ¶ モデルのテーブルにフィールドを表すための列(時には複数)を追加します。フィールドに db_index=True や unique=True が設定されている場合、インデックスやユニーク制約も追加されます。 フィールドが through の値なしで ManyToManyField の場 ... ... Index ( fields = [ "last_name" , "first_name" ]), models . Index ( fields = [ "first_name" ], name = "first_name_idx" ), ] unique_together ¶ Options. unique_together ¶ 代わりに UniqueConstraint を constraints オプションとともに使用してください。 Unique ... Constraint は unique_together よりも多くの機能を提供します。 unique_together は将来廃止される可能性があります。 組み合わせが一意でなければならな ... いフィールドのリストを指定します。 unique_together = [[ "driver" , "restaurant" ]] これは、一緒に考えたときに一意でなければならないリストのリストです。Django の管理 ... ... Index ( fields = [ "last_name" , "first_name" ]), models . Index ( fields = [ "first_name" ], name = "first_name_idx" ), ] unique_together ¶ Options. unique_together ¶ 代わりに UniqueConstraint を constraints オプションとともに使用してください。 Unique ... Constraint は unique_together よりも多くの機能を提供します。 unique_together は将来廃止される可能性があります。 組み合わせが一意でなければならな ... いフィールドのリストを指定します。 unique_together = [[ "driver" , "restaurant" ]] これは、一緒に考えたときに一意でなければならないリストのリストです。Django の管理 ... ... baseSchemaEditor. remove_constraint ( model , constraint ) [ソース] ¶ model のテーブルから constraint を削除します。 alter_unique_together() ¶ BaseDatabaseSchemaEditor. alter_unique_together ( model , old_unique_together , new_unique_together ) [ソース ... ] ¶ モデルの unique_together 値を変更します。これにより、新しい値に一致するまで、モデルのテーブルからユニーク制約が追加または削除されます。 al ... l , field ) [ソース] ¶ モデルのテーブルにフィールドを表すための列(時には複数)を追加します。フィールドに db_index=True や unique=True が設定されている場合、インデックスやユニーク制約も追加されます。 フィールドが through の値なしで ManyToManyField の場 ... 2026年10月08日