ModelForm.__init__() should match argument signature of "standard" forms
|Reported by:||James Bennett||Owned by:||nobody|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
ModelForm.__init__() differs from the
__init__() of a "standard" newforms form in two ways:
- It requires an instance of the model to be passed in, and cannot fall back to a default.
- It requires this to be the first positional argument, while on "standard" forms the first positional argument is
A number of use cases -- particularly generic form-handling code -- would be made much simpler if instead
instance was optional (with
ModelForm falling back to creating an instance based on
_meta.model if it's not supplied), and if it was moved further back in the list of arguments so as to allow code to work with the standard argument signature of
BaseForm.__init__() as much as possible.