ModelFormset ignores form properties
|Reported by:||andrew.mcmurry@…||Owned by:||jkocherhans|
|Cc:||justin1@…, james@…, alan.justino@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The implementation of modelformset_factory and inlineformset_factory ignore 'fields' and 'excludes' attributes of the supplied form (in fact all of Meta), and only use the values passed to the factory function.
Also the ModelFormset and InlineFormset 'save' method ignores the 'save' method of the supplied form.
class MyModelForm (django.forms.models.ModelForm): class Meta: model = models.MyModel fields = ('field1', 'field2') def save(self): m = super(MyModelForm, self).save() do_something_with(m) return m MyFormSet = modelformset_factory(models.MyModel, MyModelForm) fset = MyFormSet()
The forms that are part of fset have all fields of models.MyModel and not just 'field1' and 'field2' as expected.
Also fset.save() will not call 'do_something_with' on the models saved.
Much of the functionality of the ModelForm is ignored when used as part of a formset. This may be intended behavior, but it is not mentioned in the manual as far as I can see, and is not what one might expect.
Change History (20)
comment:1 Changed 7 years ago by ericholscher
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:2 Changed 7 years ago by brosner
- milestone set to 1.0
- Triage Stage changed from Design decision needed to Accepted
comment:8 Changed 7 years ago by jkocherhans
- Owner changed from justinf to jkocherhans
- Status changed from new to assigned
comment:9 follow-up: ↓ 12 Changed 6 years ago by alanjds
- milestone set to 1.1
- Version changed from SVN to 1.1-beta-1