From 9fb0f5dddc4cf7f2d294af1bcde2c359cffd90a5 Mon Sep 17 00:00:00 2001 From: Marc Tamlyn Date: Sat, 24 May 2014 10:52:18 +0100 Subject: 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. --- django/forms/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django/forms/forms.py') diff --git a/django/forms/forms.py b/django/forms/forms.py index f868165977..b5cf17f4eb 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -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 -- cgit v1.3