Miscellaneous¶
formset_class¶
The formset_class option should be used if you intend to customize your
InlineFormSet and its associated formset methods.
As the InlineFormSet isn’t actually a sub-class of the Django
BaseInlineFormSet, to achieve that, you need to define your own formset
class which extends the Django BaseInlineFormSet.
For example, imagine you’d like to add your custom clean method
for a formset. Then, define a custom formset class, a subclass of Django
BaseInlineFormSet, like this:
from django.db import models
class MyCustomInlineFormSet(BaseInlineFormSet):
def clean(self):
# ...
# Your custom clean logic goes here
Now, in your InlineFormSet sub-class, use your formset class via
formset_class setting, like this:
from extra_views import InlineFormSet
class MyInlineFormSet(InlineFormSet):
model = SomeModel
form_class = SomeForm
formset_class = MyCustomInlineFormSet # enables our custom inline
This will enable clean method being executed on your
MyInLineFormSet.