From 91e69b3564108dd5ceb689c832c98d287fb8359e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 9 Dec 2024 13:16:31 +0300 Subject: [PATCH] Update model_field_checks.py --- src/extra_checks/checks/model_field_checks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/extra_checks/checks/model_field_checks.py b/src/extra_checks/checks/model_field_checks.py index 96448b4..725cd3e 100644 --- a/src/extra_checks/checks/model_field_checks.py +++ b/src/extra_checks/checks/model_field_checks.py @@ -306,8 +306,9 @@ def apply( ): return check = f'models.Q({in_name}=[{", ".join([self._repr_choice(c) for c in field_choices])}])' + arg_name = "condition" if django.VERSION >= (5, 1) else "check" yield self.message( "Field with choices must have companion CheckConstraint to enforce choices on database level.", - hint=f'Add to Meta.constraints: `models.CheckConstraint(name="%(app_label)s_%(class)s_{field.name}_valid", condition={check})`', + hint=f'Add to Meta.constraints: `models.CheckConstraint(name="%(app_label)s_%(class)s_{field.name}_valid", {arg_name}={check})`', obj=field, )