I have a complex form (not using django-widgets) with dynamic sections where each section will have input elements for different models (say 10 models).
The user can add input to a section and click on the add button to add another section of data to the same input fields of same type.
I got to save this via sending in fetch() right ?
But what do I have to do to save this fairly big bunch of data on the python side ?
Or you can post the entire form if that’s what you want to do.
It’ll be up to you to pull the data from request.POST
and know how to assign it to the appropriate objects.
How do I post a form containing an array of multiple models ?
You don’t post models. You’re posting a form. Models exist in the server. The html form exists in the browser.
I understand - but how do I post a form containing an array of fields representing multiple models ?
The same way you post any other form in Django.
What you’re posting is form data. It is all stored in request.POST
as mentioned above.
If this data maps directly to Django forms, then you bind the html form data to those forms in exactly the same way you do it with any other form.
If you’re not creating Django forms with a 1-to-1 relationship to the HTML form fields, then it’s up to you to extract the data from request.POST
and clean/validate that data, and assign it to the appropriate variables.