provide declarative syntax to define FormSets - including ModelFormSet and InlineFormSet
|Reported by:||Owned by:||nobody|
|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 (9)
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|