[Django]-Nested Django Forms: 'ManagementForm data is missing or has been tampered with'

5👍

You should use only one <form> tag. You can have as many submit button as you want here and can display as many forms as you want, but all should be inside a single <form> tag.

Then all the management data will be sent properly in form submit and your issue should be fixed.

<form method="post" action="">
{{ tags_formset.management_form }}

<!-- code displaying this formset -->
...
<!-- -->


    {{ add_all_form.management_form }}
    {{ add_all_form.addTagsToAll }}
    <input type="submit" value="Add To Displayed Applicants" />


>
    {{ remove_all_form.management_form }}
    {{ remove_all_form.removeTagsFromAll }}
    <input type="submit" value="Remove From Displayed Applicants" />
<input type="submit" value="Save Changes" />

Your view can remain as it is.

Leave a comment