1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[5.0.x] Fixed #35560 -- Made Model.full_clean() ignore GeneratedFields for constraints.

Accessing generated field values on unsaved models caused a crash when
validating CheckConstraints and UniqueConstraints with expressions.

Backport of 1005c2abd1 from main.
This commit is contained in:
Mark Gensler
2024-06-25 15:04:48 +01:00
committed by Sarah Boyce
parent 03b908ffed
commit 0602fc2124
4 changed files with 126 additions and 2 deletions

View File

@@ -1251,7 +1251,7 @@ class Model(AltersData, metaclass=ModelBase):
field_map = {
field.name: Value(getattr(self, field.attname), field)
for field in meta.local_concrete_fields
if field.name not in exclude
if field.name not in exclude and not field.generated
}
if "pk" not in exclude:
field_map["pk"] = Value(self.pk, meta.pk)