I have use-cases, when a formset does not get rendered in the page. In this case request.POST
does not contain management data.
How can I manually add missing management data? request.POST
QueryDict is read only.
As the answer suggests, I used:
request_post_copy = request.POST.copy()
if not request_post_copy.has_key('form-TOTAL_FORMS'):
request_post_copy.update({
'form-TOTAL_FORMS': 0,
'form-INITIAL_FORMS': 0,
'form-MAX_NUM_FORMS': 1000,
})
If the error is that management form data is missing, then management form data IS missing.
Take a look at this: https://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-a-formset-in-views-and-templates
In the example they use this to display additional fields:
And if those fields are missing then you get the error you are seeing.
Edit:
If you want to add management fields manually to data, then you need to add 3 key/value pairs for fields like :
Do something like this: