These formsets are exhibiting exactly the opposite behavior that I want.
My view is set up like this:
def post(request): # TODO: handle vehi
Well... this makes the first form required.
class RequiredFormSet(BaseFormSet):
def clean(self):
if any(self.errors):
return
if not self.forms[0].has_changed():
raise forms.ValidationError('Please add at least one vehicle.')
Only "problem" is that if there are 0 forms, then the clean
method doesn't seem to get called at all, so I don't know how to check if there are 0. Really...this should never happen though (except that my JS has a bug in it, allowing you to remove all the forms).