mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #25431 -- Readded inline foreign keys to modelformset instances
Too much field exclusions in form's construct_instance() in _post_clean()
could lead to some unexpected missing ForeignKey values.
Fixes a regression from 45e049937. Refs #13776.
			
			
This commit is contained in:
		| @@ -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 | ||||
| @@ -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: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user