BaseInlineFormSet
that demonstrates how you can require a user to enter at least one entry in an inline formset.After updating to wadofstuff.django.forms 1.1.0 you can use the
RequireOneFormSet
class as the formset
argument to inlineformset_factory()
.When the formset is validated and it does not contain one or more entries, then a
ValidationError
is raised which gets put into formset.non_form_errors
. You will need to check this in your templates if you wish to display the error message to your users.
4 comments:
Hi,
I know that this might be a stupid question but is this meant to be used with the Improved FormWizard? If so how would you go about implementing it?
Hi,
Sorry RequireOneFormSet can't be used with BoundFormWizard as it subclasses BaseInlineFormSet and the wizard classes don't support inline formsets. You could try reimplementing it as a subclass of BaseFormSet then you would pass the new class you've written as the formset argument to formset_factory().
Thanks! Simple and clean.
that´s not working of you delete all rows within a formset, because the clean-method is not called.
Post a Comment