mirror of
https://github.com/django/django.git
synced 2025-11-20 11:36:04 +00:00
Fixed #36730 -- Fixed constraint validation crash for excluded FK attnames.
Regression in e44e8327d3.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
parent
5401b125ab
commit
abfa4619fb
3 changed files with 39 additions and 2 deletions
|
|
@ -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."]})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue