1
0
mirror of https://github.com/django/django.git synced 2025-10-26 23:26:08 +00:00

Fixed #25349 -- Allowed a ModelForm to unset a fields with blank=True, required=False.

This commit is contained in:
haxoza
2015-11-14 17:38:27 +01:00
committed by Tim Graham
parent 5c31d8d189
commit 375e1cfe2b
3 changed files with 46 additions and 6 deletions

View File

@@ -376,11 +376,6 @@ class BaseModelForm(BaseForm):
exclude = self._get_validation_exclusions()
try:
self.instance = construct_instance(self, self.instance, opts.fields, exclude)
except ValidationError as e:
self._update_errors(e)
# Foreign Keys being used to represent inline relationships
# are excluded from basic field value validation. This is for two
# reasons: firstly, the value may not be supplied (#12507; the
@@ -392,6 +387,11 @@ class BaseModelForm(BaseForm):
if isinstance(field, InlineForeignKeyField):
exclude.append(name)
try:
self.instance = construct_instance(self, self.instance, opts.fields, opts.exclude)
except ValidationError as e:
self._update_errors(e)
try:
self.instance.full_clean(exclude=exclude, validate_unique=False)
except ValidationError as e: