ModelForm too many restrictions.
|Reported by:||bear330||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Originally, I used form_for_model for form generation from model and worked fine.
After form_for_model deprecated, I try to use ModelForm instead, but some problems I occurred.
First, I never use form.save() method to save my model instance. My preferred way is to get data from form, do some required processes, and set it to my model instance then save it.
ModelForm implementation forces me to pass a model instance in form's constructor. This is not backward compatible. All of my view must pass a useless model instance to it.
I don't mind to change my code to follow django's new development version, but this parameter is not necessary for people who don't need to use form.save() feature.
I just want to generate a form from declared model. That's all I need..
ModelForm implementation tied 'generate a form from model' feature and 'save a form which generated from model' feature together. This truly bothered me.
For the same reason, the ModelForm implementation restricts multiple inheritance from two or more form generated from model. All of that are for form.save() method.
I think the form.save is a great feature in newforms library, but it shouldn't restrict the people who don't need it. All validations can be done in form.save method and can raise exceptions if form is not fulfill the requirement but in form generation.