mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #35223 -- Made Model.full_clean() ignore fields with db_default when validating empty values.
Thanks Brian Ibbotson for the report.
Regression in 7414704e88.
This commit is contained in:
committed by
Mariusz Felisiak
parent
1669e54965
commit
1570ef02f3
@@ -29,6 +29,7 @@ from django.db import (
|
||||
from django.db.models import NOT_PROVIDED, ExpressionWrapper, IntegerField, Max, Value
|
||||
from django.db.models.constants import LOOKUP_SEP
|
||||
from django.db.models.deletion import CASCADE, Collector
|
||||
from django.db.models.expressions import DatabaseDefault
|
||||
from django.db.models.fields.related import (
|
||||
ForeignObjectRel,
|
||||
OneToOneField,
|
||||
@@ -1633,6 +1634,9 @@ class Model(AltersData, metaclass=ModelBase):
|
||||
raw_value = getattr(self, f.attname)
|
||||
if f.blank and raw_value in f.empty_values:
|
||||
continue
|
||||
# Skip validation for empty fields when db_default is used.
|
||||
if isinstance(raw_value, DatabaseDefault):
|
||||
continue
|
||||
try:
|
||||
setattr(self, f.attname, f.clean(raw_value, self))
|
||||
except ValidationError as e:
|
||||
|
||||
Reference in New Issue
Block a user