File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -1607,7 +1607,9 @@ def get_unique_together_validators(self):
1607
1607
source_map [source ].append (name )
1608
1608
1609
1609
unique_constraint_by_fields = {
1610
- constraint .fields : constraint for constraint in self .Meta .model ._meta .constraints
1610
+ constraint .fields : constraint
1611
+ for model_cls in (self .Meta .model , * self .Meta .model ._meta .parents )
1612
+ for constraint in model_cls ._meta .constraints
1611
1613
if isinstance (constraint , models .UniqueConstraint )
1612
1614
}
1613
1615
Original file line number Diff line number Diff line change @@ -627,13 +627,7 @@ class Meta:
627
627
fields = ("username" , "company_id" ),
628
628
name = "unique_username_company_custom_msg" ,
629
629
violation_error_message = "Username must be unique within a company." ,
630
- violation_error_code = "duplicate_username" ,
631
- )
632
- if django_version [0 ] >= 5
633
- else models .UniqueConstraint (
634
- fields = ("username" , "company_id" ),
635
- name = "unique_username_company_custom_msg" ,
636
- violation_error_message = "Username must be unique within a company." ,
630
+ ** (dict (violation_error_code = "duplicate_username" ) if django_version [0 ] >= 5 else {}),
637
631
),
638
632
models .UniqueConstraint (
639
633
fields = ("company_id" , "role" ),
You can’t perform that action at this time.
0 commit comments