Multiple ModelForms on One Page


I am trying to create a dynamic page that presents/updates multiple ModelForms using Class-based-views. I have created single pages that modify the Model objects separately. However, what I really want to do is to have them all on one page like so:

I hope the sketch is self-explanatory. Users should be able to add/remove Shelves dynamically and the books likewise. Removing a shelf removes the child-objects (books). That is already possible via on_delete=CASCADE on database level.

So … does anyone have an idea of the best approach to this?

That sort of dynamic page requires JavaScript to do the work in the browser.

If you’re working with multiple instances of the same form, you would use formsets in Django to initially prepare the page, and then the JavaScript in the browser to perform the modifications to the page after it has been rendered in the browser.

Note: The Django-provided generic Class Based Views are not going to be your friend here.