From abfa4619fb818ff694c22e962a280673e085239e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 12 Nov 2025 19:47:16 +0000 Subject: Fixed #36730 -- Fixed constraint validation crash for excluded FK attnames. Regression in e44e8327d3d88d86895735c0e427102063ff5b55. Co-authored-by: Mariusz Felisiak --- tests/model_forms/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/model_forms/tests.py') diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py index f0334e1e86..129ce56c7a 100644 --- a/tests/model_forms/tests.py +++ b/tests/model_forms/tests.py @@ -30,6 +30,7 @@ from django.utils.version import PY314, PYPY from .models import ( Article, ArticleStatus, + AttnameConstraintsModel, Author, Author1, Award, @@ -3766,3 +3767,17 @@ class ConstraintValidationTests(TestCase): self.assertEqual( full_form.errors, {"__all__": ["Price must be greater than zero."]} ) + + def test_check_constraint_refs_excluded_field_attname(self): + left = AttnameConstraintsModel.objects.create() + instance = AttnameConstraintsModel.objects.create(left=left) + data = { + "left": str(left.id), + "right": "", + } + AttnameConstraintsModelForm = modelform_factory( + AttnameConstraintsModel, fields="__all__" + ) + full_form = AttnameConstraintsModelForm(data, instance=instance) + self.assertFalse(full_form.is_valid()) + self.assertEqual(full_form.errors, {"right": ["This field is required."]}) -- cgit v1.3