﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7289	ModelForm metaclass doesn't remove declared Field attributes	Daniel Pope <dan@…>	nobody	"With normal forms, writing

{{{
class FooForm(forms.Form):
    myfoo = forms.CharField()

form = FooForm()
}}}

creates a class where {{{form.myfoo}}} gives an attribute error: the !CharField is moved to {{{FooForm.base_fields['myfoo']}}} by the metaclass and deep-copied to {{{form.fields['myfoo']}}} by the constructor. With an equivalent !ModelForm, this doesn't happen and {{{form.myfoo}}} and {{{form.fields['myfoo']}}} both refer to a !CharField instance.

This would be just a slight incompatibility, except that {{{del(form.fields['myfoo'])}}} should remove the field from the form - this is the intended behaviour for standard Forms. With !ModelForms, the spurious attribute means that, in a template,{{{ {{form.myfoo}} }}}falls back to displaying the repr of the !CharField (eg. <django.newforms.fields.!CharField object at 0x1fb0a90>) instead of nothing. To delete fields from a !ModelForm you need to write

{{{
del(form['myfoo'])
del(form.foo)
}}}"		closed	Forms	dev		fixed			Accepted	1	0	0	0	0	0
