mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #22510 -- Harden field removal to only None.
Refs #8620. If we allow any value to remove form fields then we get name clashes with method names, media classes etc. There was a backwards incompatibility introduced meaning ModelForm subclasses with declared fields called media or clean would lose those fields. Field removal is now only permitted by using the sentinel value None. The docs have been slightly reworded to refer to removal of fields rather than shadowing. Thanks to gcbirzan for the report and initial patch, and several of the core team for opinions.
This commit is contained in:
		| @@ -92,8 +92,8 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass): | ||||
|                 declared_fields.update(base.declared_fields) | ||||
|  | ||||
|             # Field shadowing. | ||||
|             for attr in base.__dict__.keys(): | ||||
|                 if attr in declared_fields: | ||||
|             for attr, value in base.__dict__.items(): | ||||
|                 if value is None and attr in declared_fields: | ||||
|                     declared_fields.pop(attr) | ||||
|  | ||||
|         new_class.base_fields = declared_fields | ||||
|   | ||||
		Reference in New Issue
	
	Block a user