Skip to content

Commit 91e69b3

Browse files
authored
Update model_field_checks.py
1 parent a4b241c commit 91e69b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/extra_checks/checks/model_field_checks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ def apply(
306306
):
307307
return
308308
check = f'models.Q({in_name}=[{", ".join([self._repr_choice(c) for c in field_choices])}])'
309+
arg_name = "condition" if django.VERSION >= (5, 1) else "check"
309310
yield self.message(
310311
"Field with choices must have companion CheckConstraint to enforce choices on database level.",
311-
hint=f'Add to Meta.constraints: `models.CheckConstraint(name="%(app_label)s_%(class)s_{field.name}_valid", condition={check})`',
312+
hint=f'Add to Meta.constraints: `models.CheckConstraint(name="%(app_label)s_%(class)s_{field.name}_valid", {arg_name}={check})`',
312313
obj=field,
313314
)

0 commit comments

Comments
 (0)