tickets: 7018
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7018 | 2008-04-14 15:57:59 | 2021-08-11 16:13:04 | 2022-03-06 03:38:31.943183 | Accepted | new | Forms | New feature | Normal | dev | Make ModelForm multiple inheritance possible | If I have two ModelForm: {{{ class AForm(ModelForm): class Meta: model = A class BForm(ModelForm): class Meta: model = B class CForm(AForm, BForm): pass }}} This doesn't work because of the code: {{{ declared_fields = get_declared_fields(bases, attrs, False) }}} in ModelFormMetaclass. I can to this to make it work: {{{ # Because ModelFormMetaclass will call get_declared_fields method with # with_base_fields=False, we modify it with True. from django.newforms import models as nmodels gdf = nmodels.get_declared_fields nmodels.get_declared_fields = \ lambda bases, attrs, with_base_fields: gdf(bases, attrs, True) }}} But it will be nice if this behavior is default behavior. Thanks. | nobody | bear330 | 0 | 0 | 0 | 0 | 0 | 0 |