... 複数のフィールドからなる主キーが必要になることもあります。 複合主キーを使用するには、モデルを定義する際に pk 属性を CompositePrimaryKey に設定します: class Product ( models . Model ): name = models . CharField ( max_length = 100 ) class Order ( models . M ... odel ): reference = models . CharField ( max_length = 20 , primary_key = True ) class OrderLineItem ( models . Model ): pk = models . CompositePrimaryKey ( "product_id" , "order_id" ) produ ... der , on_delete = models . CASCADE ) quantity = models . IntegerField () これにより、Django はテーブル作成時に複合主キー( PRIMARY KEY (product_id, order_id) )を作成するようになります。 複合主キーは tuple (タプル)で表現されます: >>> product = Product ... ... 複数のフィールドからなる主キーが必要になることもあります。 複合主キーを使用するには、モデルを定義する際に pk 属性を CompositePrimaryKey に設定します: class Product ( models . Model ): name = models . CharField ( max_length = 100 ) class Order ( models . M ... odel ): reference = models . CharField ( max_length = 20 , primary_key = True ) class OrderLineItem ( models . Model ): pk = models . CompositePrimaryKey ( "product_id" , "order_id" ) produ ... der , on_delete = models . CASCADE ) quantity = models . IntegerField () これにより、Django はテーブル作成時に複合主キー( PRIMARY KEY (product_id, order_id) )を作成するようになります。 複合主キーは tuple (タプル)で表現されます: >>> product = Product ... ... erity "moderate" according to the Django security policy . CVE-2026-87975: Privilege abuse in model formsets with editable primary keys ¶ Model formsets incorrectly allowed forged POST data to either delete instances outside the limiting queryset or cre ... ate instances via edit-only formsets when the model's primary key could be set through the form, such as with: a OneToOneField (or parent link used as the primary key of an inline form ... set's model), or a natural or UUID primary key included in the form's fields. Models using the default BigAutoField primary key were not affected. This issue has sev ... ... erity "moderate" according to the Django security policy . CVE-2026-87975: Privilege abuse in model formsets with editable primary keys ¶ Model formsets incorrectly allowed forged POST data to either delete instances outside the limiting queryset or cre ... ate instances via edit-only formsets when the model's primary key could be set through the form, such as with: a OneToOneField (or parent link used as the primary key of an inline form ... set's model), or a natural or UUID primary key included in the form's fields. Models using the default BigAutoField primary key were not affected. This issue has sev ... ... erity "moderate" according to the Django security policy . CVE-2026-87975: Privilege abuse in model formsets with editable primary keys ¶ Model formsets incorrectly allowed forged POST data to either delete instances outside the limiting queryset or cre ... ate instances via edit-only formsets when the model's primary key could be set through the form, such as with: a OneToOneField (or parent link used as the primary key of an inline form ... set's model), or a natural or UUID primary key included in the form's fields. Models using the default BigAutoField primary key were not affected. This issue has sev ... ... erity "moderate" according to the Django security policy . CVE-2026-87975: Privilege abuse in model formsets with editable primary keys ¶ Model formsets incorrectly allowed forged POST data to either delete instances outside the limiting queryset or cre ... ate instances via edit-only formsets when the model's primary key could be set through the form, such as with: a OneToOneField (or parent link used as the primary key of an inline form ... set's model), or a natural or UUID primary key included in the form's fields. Models using the default BigAutoField primary key were not affected. This issue has sev ... ... erity "moderate" according to the Django security policy . CVE-2026-87975: Privilege abuse in model formsets with editable primary keys ¶ Model formsets incorrectly allowed forged POST data to either delete instances outside the limiting queryset or cre ... ate instances via edit-only formsets when the model's primary key could be set through the form, such as with: a OneToOneField (or parent link used as the primary key of an inline form ... set's model), or a natural or UUID primary key included in the form's fields. Models using the default BigAutoField primary key were not affected. This issue has sev ... ... erity "moderate" according to the Django security policy . CVE-2026-87975: Privilege abuse in model formsets with editable primary keys ¶ Model formsets incorrectly allowed forged POST data to either delete instances outside the limiting queryset or cre ... ate instances via edit-only formsets when the model's primary key could be set through the form, such as with: a OneToOneField (or parent link used as the primary key of an inline form ... set's model), or a natural or UUID primary key included in the form's fields. Models using the default BigAutoField primary key were not affected. This issue has sev ... ... QL when renaming a field to AutoField in PostgreSQL ( #24892 ). Fixed lack of unique constraint when changing a field from primary_key=True to unique=True ( #24893 ). Fixed queryset pickling when using prefetch_related() after deleting objects ( #24831 ... by casting it to an integer ( #24769 ). Fixed prefetch_related() on databases other than PostgreSQL for models using UUID primary keys ( #24912 ). Fixed removing unique_together constraints on MySQL ( #24972 ). Fixed crash when uploading images with MI ... n 3 by fixing the false positive system check ( #25016 ). Fixed inline forms that use a parent object that has a UUIDField primary key and a child object that has an AutoField primary key ( #24958 ). Fixed a regression in the unordered_list template fil ... ... QL when renaming a field to AutoField in PostgreSQL ( #24892 ). Fixed lack of unique constraint when changing a field from primary_key=True to unique=True ( #24893 ). Fixed queryset pickling when using prefetch_related() after deleting objects ( #24831 ... by casting it to an integer ( #24769 ). Fixed prefetch_related() on databases other than PostgreSQL for models using UUID primary keys ( #24912 ). Fixed removing unique_together constraints on MySQL ( #24972 ). Fixed crash when uploading images with MI ... n 3 by fixing the false positive system check ( #25016 ). Fixed inline forms that use a parent object that has a UUIDField primary key and a child object that has an AutoField primary key ( #24958 ). Fixed a regression in the unordered_list template fil ... 2026年10月08日