tickets: 7837
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7837 | 2008-07-19 15:18:23 | 2014-06-08 05:29:47 | 2022-03-06 03:40:41.273035 | Accepted | closed | Forms | Bug | Normal | dev | fixed | Hierarchy in forms metaclasses can miss declarated fields in forms | This was occurs after [7847]. Ok, [7847] is a good commit for make able to metaclass subclassing. This is the scenary: {{{ #!python #### model class FooModel(models.Model): name = models.CharField(max_length=100) #### forms class GenericForm(forms.Form): extra_field = forms.CharField() class FooForm(GenericForm, forms.ModelForm): # to avoid python metaclass conflict error: __metaclass__ = type('FooFormMetaclass', (GenericForm.__metaclass__, forms.ModelForm.__metaclass__), {}) non_existing_field = forms.CharField() class Meta: model = FooModel }}} In previous scenario, {{{FooForm}}} should contain both {{{name}}}, {{{extra_field}}} and {{{nonexisting_field}}}. But only appears {{{name}}} field in {{{base_fields}}}. See this test: {{{ #!python >>> from testapp.forms import FooForm >>> FooForm.base_fields.keys() ['name'] }}} I will attach a patch thats fixes problem. | msaelices | msaelices | 0 | 1 | 1 | 0 | 0 | 0 |