@@ -753,19 +753,19 @@ def contribute_to_class(
753
753
elif self .constrained and self .enum :
754
754
constraint = Q (
755
755
** {
756
- f"{ name } __in" : [
756
+ f"{ self . name or name } __in" : [
757
757
self ._coerce_to_value_type (value ) for value in values (self .enum )
758
758
]
759
759
}
760
760
)
761
761
if self .null :
762
- constraint |= Q (** {f"{ name } __isnull" : True })
762
+ constraint |= Q (** {f"{ self . name or name } __isnull" : True })
763
763
cls ._meta .constraints = [
764
764
* cls ._meta .constraints ,
765
765
CheckConstraint (
766
- ** { # type: ignore[arg-type ]
766
+ ** { # type: ignore[call-overload ]
767
767
condition : constraint ,
768
- "name" : self .constraint_name (cls , name , self .enum ),
768
+ "name" : self .constraint_name (cls , self . name or name , self .enum ),
769
769
}
770
770
),
771
771
]
@@ -1185,19 +1185,21 @@ def contribute_to_class(
1185
1185
1186
1186
if is_strict or is_conform or (is_eject and self .strict ) and flags :
1187
1187
constraint = (
1188
- Q (** {f"{ name } __gte" : min (* flags )})
1189
- & Q (** {f"{ name } __lte" : reduce (or_ , flags )})
1190
- ) | Q (** {name : 0 })
1188
+ Q (** {f"{ self . name or name } __gte" : min (* flags )})
1189
+ & Q (** {f"{ self . name or name } __lte" : reduce (or_ , flags )})
1190
+ ) | Q (** {self . name or name : 0 })
1191
1191
1192
1192
if self .null :
1193
- constraint |= Q (** {f"{ name } __isnull" : True })
1193
+ constraint |= Q (** {f"{ self . name or name } __isnull" : True })
1194
1194
1195
1195
cls ._meta .constraints = [
1196
1196
* cls ._meta .constraints ,
1197
1197
CheckConstraint (
1198
1198
** {
1199
1199
condition : constraint ,
1200
- "name" : self .constraint_name (cls , name , self .enum ),
1200
+ "name" : self .constraint_name (
1201
+ cls , self .name or name , self .enum
1202
+ ),
1201
1203
}
1202
1204
),
1203
1205
]
0 commit comments