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:
committed by
Sarah Boyce
parent
03b908ffed
commit
0602fc2124
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user