Skip to content

Commit 7414cf6

Browse files
authored
Fix: do not access CheckConstraint.check on django >=5.1
1 parent fc37cca commit 7414cf6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/extra_checks/checks/model_field_checks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,11 @@ def apply(
295295
field_choices.append("")
296296
in_name = f"{field.name}__in"
297297
for constraint in model._meta.constraints:
298-
if isinstance(constraint, models.CheckConstraint) and isinstance(
299-
constraint.check, models.Q
300-
):
301-
for entry in constraint.check.children:
298+
if isinstance(constraint, models.CheckConstraint):
299+
condition = constraint.check if django.VERSION < (5, 1) else constraint.condition
300+
if not isinstance(condition, models.Q):
301+
continue
302+
for entry in condition.children:
302303
if (
303304
isinstance(entry, tuple)
304305
and entry[0] == in_name

0 commit comments

Comments
 (0)