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):
16071607 source_map [source ].append (name )
16081608
16091609 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
16111613 if isinstance (constraint , models .UniqueConstraint )
16121614 }
16131615
Original file line number Diff line number Diff line change @@ -627,13 +627,7 @@ class Meta:
627627 fields = ("username" , "company_id" ),
628628 name = "unique_username_company_custom_msg" ,
629629 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 {}),
637631 ),
638632 models .UniqueConstraint (
639633 fields = ("company_id" , "role" ),
You can’t perform that action at this time.
0 commit comments