File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 1- # Generated by Django 5.2.4 on 2025-09-14 04:17
1+ # Generated by Django 5.2.4 on 2025-09-14 05:04
22
33import django .contrib .auth .models
44import django .core .validators
@@ -943,6 +943,11 @@ class Migration(migrations.Migration):
943943 name = "unique_fields-sub_title_en" ,
944944 ),
945945 ],
946+ "unique_together" : {
947+ ("title" , "sub_title" ),
948+ ("title" , "sub_title_de" ),
949+ ("title" , "sub_title_en" ),
950+ },
946951 },
947952 ),
948953 migrations .CreateModel (
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class ModelWithConstraint(models.Model):
2727 sub_title = models .CharField (max_length = 255 )
2828
2929 class Meta :
30+ unique_together = (("title" , "sub_title" ),)
3031 constraints = [
3132 models .UniqueConstraint (
3233 fields = ["title" , "sub_title" ],
Original file line number Diff line number Diff line change @@ -357,6 +357,10 @@ def add_constraints():
357357
358358 model ._meta .unique_together += tuple (add_unique_together ()) # type: ignore[operator]
359359 model ._meta .constraints += tuple (add_constraints ())
360+ # `unique_together` needs `original_attrs` to be set, for this changes to appear in migrations.
361+ for attr_name in ("unique_together" ,):
362+ if value := getattr (model ._meta , attr_name ):
363+ model ._meta .original_attrs [attr_name ] = value
360364
361365
362366def delete_mt_init (sender : type [Model ], instance : Model , ** kwargs : Any ) -> None :
You can’t perform that action at this time.
0 commit comments