Troubleshooting Formsets

I have a formset that is returning False for fomset.is_valid(). formset.errors print empty [ ]. How do I begin to troubleshoot a formset? Where do I look?

Things to look at:

  • Error messages on the console associated with the submission of the form?

  • Overriding any of the default behavior of the formset in the view?

  • Performing any dynamic modification of the formset on the client side?

  • Verify that the data being submitted is correct?

  • Verify that the view handling the post is properly rebuilding the formset from the submitted data?

If none of that is providing any real clues, then my next steps would be to either run it in the debugger to see what’s happening, or start sprinkling print statements in at multiple places to figure out what’s going on.

Someone on #django IRC channel in liberachat solved it:
The issue was with formset.management_form. I did not include {{ myformset.management_form }} in the template so INITIAL_FORM and TOTAL_FORMS values were missing. I needed to look at formset.management_form.errors instead.