[Django]-Django formsets required

0👍

It’s a bit hard to understand where the errors are not being displayed.

If is_valid is False, then good, the validation it self is working. Then the next place to look is for the templating layer. How are you checking for errors? {{form.errors}} or {{somefield.errors}}.

The way the clean methods are setup here, their errors will not be associated with any fields, but should go in the all erros slot.

Cheers

0👍

I had this same problem and figured out where these errors were stored by checking the source. When you override the clean method of a formset and raise a validation error the errors are stored in the non_form_errors property.

So in your template you would need to add the following assuming the template variable for formset is named ‘formset’:

{{ formset.non_form_errors }}

Leave a comment