Need help

30 views
Skip to first unread message

Rohit Lohar

unread,
Jun 22, 2022, 10:56:39 AMJun 22
to Django users
The below image consists of a form layout the main form has it's model defined and the subform has it's own model defined but I am getting problem that how should I implement and also the subform is dynamic so how can I implement it using htmx. Your help is appreciated. Thank you
screenshot (2).png

K Wong

unread,
Jul 4, 2022, 6:45:00 PMJul 4
to Django users
I've implemented this sort of thing in the past. Without knowing your specific case, I guess that you have a parent model (ie. Pizza) and 1-n related child models (ie. Topping).

My advice is to redesign your flow to create a Pizza first then attach 1-n Topping entities to it. This would require two views and two forms.

If you want it all in one go, then write an API in REST Framework that does what I just said but via two calls from a single HTML page. You can write the HTML DOM manipulation in jQuery or ReactJS or whatever you are comfortable with. You will still end up with two calls: one to create your Pizza parent entity then subsequent calls to make Topping instances.

-k
Reply all
Reply to author
Forward
0 new messages