... 、次のように記述します: 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 = N ... opclasses = () , 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 ... ... が 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 ... ... Index ( fields = [ "last_name" , "first_name" ]), models . Index ( fields = [ "first_name" ], name = "first_name_idx" ), ] unique_together Options. unique_together 代わりに UniqueConstraint を constraints オプションとともに使用してください。 UniqueCons ... traint は unique_together よりも多くの機能を提供します。 unique_together は将来廃止される可能性があります。 組み合わせが一意でなければならな ... いフィールドのリストを指定します。 unique_together = [[ "driver" , "restaurant" ]] これは、一緒に考えたときに一意でなければならないリストのリストです。Django の管理 ... ... tabaseSchemaEditor. remove_constraint ( model , constraint ) [ソース] model のテーブルから constraint を削除します。 alter_unique_together() BaseDatabaseSchemaEditor. alter_unique_together ( model , old_unique_together , new_unique_together ) [ソース] ... モデルの unique_together 値を変更します。これにより、新しい値に一致するまで、モデルのテーブルからユニーク制約が追加または削除されます。 al ... del , field ) [ソース] モデルのテーブルにフィールドを表すための列(時には複数)を追加します。フィールドに db_index=True や unique=True が設定されている場合、インデックスやユニーク制約も追加されます。 フィールドが through の値なしで ManyToManyField の場 ... ... あります: Validate the model fields - Model.clean_fields() Validate the model as a whole - Model.clean() Validate the field uniqueness - Model.validate_unique() 制約を検証する - Model.validate_constraints() モデルの full_clean() メソッドを使うと、4 つ全 ... , or if you have excluded fields from the ModelForm that require validation. Model. full_clean ( exclude = None , validate_unique = True , validate_constraints = True ) [ソース] This method calls Model.clean_fields() , Model.clean() , Model.validate_un ... ique() (if validate_unique is True ), and Model.validate_constraints() (if validate_constraints is True ) in that order and raises a ValidationError ... ... 7 ). 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 regression where defining a relation on an abstract ... ... me" ) >>> # Condition can be created using boolean expressions. >>> from django.db.models import Exists , OuterRef >>> non_unique_account_type = ( ... Client . objects . filter ( ... account_type = OuterRef ( "account_type" ), ... ) ... . exclude ( pk ... = OuterRef ( "pk" )) ... . values ( "pk" ) ... ) >>> When ( Exists ( non_unique_account_type ), then = Value ( "non unique" )) >>> # Condition can be created using lookup expressions. >>> from django.db ... それを直接フィルタで使用できます。つまり、 SELECT カラムには追加されませんが、結果のフィルタリングには使用できます: >>> non_unique_account_type = ( ... Client . objects . filter ( ... account_type = OuterRef ( "account_type" ), ... ) ... . exclude ( pk ... ... m validation step right after the form's clean() method is called. First, the model's full_clean() is called with validate_unique=False and validate_constraints=False , then the model's validate_unique() and validate_constraints() methods are called in ... にアクセスできるようにします。 警告 The ModelForm.clean() method sets flags that make the model validation step validate the uniqueness of model fields that are marked as unique , unique_together or unique_for_date|month|year , as well as constraints. cl ... 方については、 フォームバリデーション ドキュメントを参照してください。 The model's clean() method will be called before any uniqueness or constraint checks are made. See Validating objects for more information on the model's clean() hook. モデルの error ... ... , mapping , layer = 0 , source_srs = None , encoding = None , transaction_mode = 'commit_on_success' , transform = True , unique = True , using = 'default' ) [ソース] 以下は LayerMapping オブジェクトのインスタンス生成時に使用できる引数とキーワードです ... ns. In other words, geometries will be inserted into the database unmodified from their original state in the data source. unique Setting this to the name, or a tuple of names, from the given model will create models unique only to the given name(s). G ... eometries from each feature will be added into the collection associated with the unique model. Forces the transaction mode to be 'autocommit' . using 空間データをインポートする際に使用するデータベースを設定しま ... 2026年10月08日