Loading django/forms/models.py +5 −5 Original line number Diff line number Diff line Loading @@ -376,6 +376,11 @@ 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 Loading @@ -387,11 +392,6 @@ class BaseModelForm(BaseForm): if isinstance(field, InlineForeignKeyField): exclude.append(name) try: self.instance = construct_instance(self, self.instance, opts.fields, exclude) except ValidationError as e: self._update_errors(e) try: self.instance.full_clean(exclude=exclude, validate_unique=False) except ValidationError as e: Loading docs/releases/1.8.5.txt +3 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,6 @@ Bugfixes * Moved the :ref:`unsaved model instance assignment data loss check <unsaved-model-instance-check-18>` on reverse relations to ``Model.save()`` (:ticket:`25160`). * Readded inline foreign keys to form instances when validating model formsets (:ticket:`25431`). tests/model_formsets/models.py +4 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,10 @@ class Book(models.Model): def __str__(self): return self.title def clean(self): # Ensure author is always accessible in clean method assert self.author.name is not None @python_2_unicode_compatible class BookWithCustomPK(models.Model): Loading Loading
django/forms/models.py +5 −5 Original line number Diff line number Diff line Loading @@ -376,6 +376,11 @@ 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 Loading @@ -387,11 +392,6 @@ class BaseModelForm(BaseForm): if isinstance(field, InlineForeignKeyField): exclude.append(name) try: self.instance = construct_instance(self, self.instance, opts.fields, exclude) except ValidationError as e: self._update_errors(e) try: self.instance.full_clean(exclude=exclude, validate_unique=False) except ValidationError as e: Loading
docs/releases/1.8.5.txt +3 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,6 @@ Bugfixes * Moved the :ref:`unsaved model instance assignment data loss check <unsaved-model-instance-check-18>` on reverse relations to ``Model.save()`` (:ticket:`25160`). * Readded inline foreign keys to form instances when validating model formsets (:ticket:`25431`).
tests/model_formsets/models.py +4 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,10 @@ class Book(models.Model): def __str__(self): return self.title def clean(self): # Ensure author is always accessible in clean method assert self.author.name is not None @python_2_unicode_compatible class BookWithCustomPK(models.Model): Loading