... れ、これがユニーク制約に違反するためです。 そのため、次の手順を踏む必要があります。この例では、デフォルト値を持つ非 Null の UUIDField を追加します。必要に応じて、該当するフィールドを変更してください。 モデルに default=uuid.uuid4 と unique=True 引数を持 ... ルのうちの最初のファイル)から AddField オペレーションを最後のマイグレーションにコピーし、 AddField を AlterField に変更し、 uuid と models のインポートを追加します。例: 0006_remove_uuid_null.py ¶ # Generated by Django A.B on YYYY-MM-DD HH:MM from djan ... go.db import migrations , models import uuid class Migration ( migrations . Migration ): dependencies = [ ( "myapp" , "0005_populate_uuid_values" ), ] operations = [ m ... ... れ、これがユニーク制約に違反するためです。 そのため、次の手順を踏む必要があります。この例では、デフォルト値を持つ非 Null の UUIDField を追加します。必要に応じて、該当するフィールドを変更してください。 モデルに default=uuid.uuid4 と unique=True 引数を持 ... ルのうちの最初のファイル)から AddField オペレーションを最後のマイグレーションにコピーし、 AddField を AlterField に変更し、 uuid と models のインポートを追加します。例: 0006_remove_uuid_null.py ¶ # Generated by Django A.B on YYYY-MM-DD HH:MM from djan ... go.db import migrations , models import uuid class Migration ( migrations . Migration ): dependencies = [ ( "myapp" , "0005_populate_uuid_values" ), ] operations = [ m ... ... D [ソース] ¶ バージョン 4 の UUID を返します。 使用例: >>> from django.contrib.postgres.functions import RandomUUID >>> Article . objects . update ( uuid = ... RandomUUID ()) Use django.db.models.functions.UUID4 instead. django.db.models.functions.UUID4 is a cross-database version of this fun ... ction. RandomUUID may be deprecated in the future. TransactionNow ¶ class TransactionNow [ソース] ¶ 現在のトランザクションが開始されたデータ ... ... D [ソース] ¶ バージョン 4 の UUID を返します。 使用例: >>> from django.contrib.postgres.functions import RandomUUID >>> Article . objects . update ( uuid = ... RandomUUID ()) Use django.db.models.functions.UUID4 instead. django.db.models.functions.UUID4 is a cross-database version of this fun ... ction. RandomUUID may be deprecated in the future. TransactionNow ¶ class TransactionNow [ソース] ¶ 現在のトランザクションが開始されたデータ ... ... されました。 QuerySet.aiterator() が以前の prefetch_related() 呼び出しをサポートするようになりました。 MariaDB 10.7 以降で、 UUIDField は CHAR(32) ではなく UUID カラムとして作成されます。詳細は、 MariaDB 10.7+ における既存の UUIDField のマイグレーション ... 前のフィールドを持つモデルは、ルックアップで create_defaults__exact を指定する必要があります。 MariaDB 10.7+ における既存の UUIDField のマイグレーション ¶ MariaDB 10.7以降では、 UUIDField は CHAR(32) カラムではなく UUID カラムとして作成されるようになり ... ました。その結果、Django < 5.0で作成された任意の UUIDField は、 CHAR(32) に基づく UUIDField サブクラスに置き換える必要があります: class Char32UUIDField ( models . UUIDField ): ... ... されました。 QuerySet.aiterator() が以前の prefetch_related() 呼び出しをサポートするようになりました。 MariaDB 10.7 以降で、 UUIDField は CHAR(32) ではなく UUID カラムとして作成されます。詳細は、 MariaDB 10.7+ における既存の UUIDField のマイグレーション ... 前のフィールドを持つモデルは、ルックアップで create_defaults__exact を指定する必要があります。 MariaDB 10.7+ における既存の UUIDField のマイグレーション ¶ MariaDB 10.7以降では、 UUIDField は CHAR(32) カラムではなく UUID カラムとして作成されるようになり ... ました。その結果、Django < 5.0で作成された任意の UUIDField は、 CHAR(32) に基づく UUIDField サブクラスに置き換える必要があります: class Char32UUIDField ( models . UUIDField ): ... ... hes its values. This is useful especially when dealing with callables whose return values can change (e.g. datetime.now or uuid.uuid4 ): >>> import uuid >>> class UUIDCommentForm ( CommentForm ): ... identifier = forms . UUIDField ( initial = uuid . ... uuid4 ) ... >>> f = UUIDCommentForm () >>> f . get_initial_for_field ( f . fields [ "identifier" ], "identifier" ) UUID('972ca9e4-7bfe-4f5b-af7d-07 ... b3aa306334') >>> f . get_initial_for_field ( f . fields [ "identifier" ], "identifier" ) UUID('1b411fab-844e-4dec-bd4f-e9b0495f04d0') >>> # Using BoundField.initial, for comparison >>> f [ "identifier" ] . initial UU ... ... hes its values. This is useful especially when dealing with callables whose return values can change (e.g. datetime.now or uuid.uuid4 ): >>> import uuid >>> class UUIDCommentForm ( CommentForm ): ... identifier = forms . UUIDField ( initial = uuid . ... uuid4 ) ... >>> f = UUIDCommentForm () >>> f . get_initial_for_field ( f . fields [ "identifier" ], "identifier" ) UUID('972ca9e4-7bfe-4f5b-af7d-07 ... b3aa306334') >>> f . get_initial_for_field ( f . fields [ "identifier" ], "identifier" ) UUID('1b411fab-844e-4dec-bd4f-e9b0495f04d0') >>> # Using BoundField.initial, for comparison >>> f [ "identifier" ] . initial UU ... ... json.JSONEncoder subclass to serialize data types not supported by the standard JSON serializer (e.g. datetime.datetime or UUID ). For example, you can use the DjangoJSONEncoder class. デフォルトは json.JSONEncoder です。 JSONField. decoder ¶ An opti ... スと同じく、 URLField は省略可能な max_length 引数を取ります。 max_length を指定しない場合、デフォルトの 200 が使われます。 UUIDField ¶ class UUIDField ( ** options ) [ソース] ¶ A field for storing universally unique identifiers. Uses Python's UUID cl ... ass. When used on PostgreSQL and MariaDB, this stores in a uuid datatype, otherwise in a char(32) . UUID は primary_key に代わる AutoField への良い選択肢です。 データベースはあなたのため ... ... json.JSONEncoder subclass to serialize data types not supported by the standard JSON serializer (e.g. datetime.datetime or UUID ). For example, you can use the DjangoJSONEncoder class. デフォルトは json.JSONEncoder です。 JSONField. decoder ¶ An opti ... スと同じく、 URLField は省略可能な max_length 引数を取ります。 max_length を指定しない場合、デフォルトの 200 が使われます。 UUIDField ¶ class UUIDField ( ** options ) [ソース] ¶ A field for storing universally unique identifiers. Uses Python's UUID cl ... ass. When used on PostgreSQL and MariaDB, this stores in a uuid datatype, otherwise in a char(32) . UUID は primary_key に代わる AutoField への良い選択肢です。 データベースはあなたのため ... 2026年10月08日