provide declarative syntax to define FormSets - including ModelFormSet and InlineFormSet
|Reported by:||Owned by:||Asif Saifuddin Auvi|
|Severity:||Normal||Keywords:||formset modelformset inlineformset|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
Provide a declarative mechanism to define modelformsets or inlineformsets.
The attached patch allows definitions like this:
class AuthorForm(forms.ModelForm): class Meta: model = Author class DeclarativeAuthorFormSet(forms.models.ModelFormSet): form = AuthorForm model = Author extra = 3
class BookForm(forms.ModelForm): class Meta: model = Book class DeclarativeAuthorBooksFormSet(forms.models.InlineFormSet): model = Book form = BookForm parent = 'author'
An advantage is that the defined form is directly used as the form class in the formset, not as a base class for a new form class (what inlineformset_factory does). This way specific field definitions and other customisations in the form work like they should so you don't need to redefine things in init().
Change History (13)
comment:1 Changed 8 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Design decision needed|
comment:3 Changed 5 years ago by
|Patch needs improvement:||set|
|Summary:||provide declarative syntax to define ModelFormSet and InlineFormSet → provide declarative syntax to define FormSets - including ModelFormSet and InlineFormSet|
comment:7 Changed 18 months ago by
|Owner:||changed from nobody to Asif Saifuddin Auvi|
|Status:||new → assigned|