Django: How To Carry Model Form Data From One Page To Another, And Back, Without Commiting To The Db?
Solution 1:
Idea A: Store the uncommitted data in the session until everything is ready for commit. Each form/roundtrip to the client just adds/updates the accumulating data. If they abandon it you only have crap lying around until the session is destroyed. You can save pretty much anything to the session.
Idea B: Add a boolean to the database table which indicates when a row has been committed (eg: "is_active" or "is_pending"). Means you never lose anything but a bit more of a nuisance to manage.
Solution 2:
Having done the very similar requirement by working around the formset tools, I completely agree that going hoops and bounds to understand/customize the formset is totally not worth it.
For a screenshot like yours, I'd use just one form with all of the slides per deck. - Form, not formset.
You should handle the slide "edit/delete/new" all in ajax requests that include the deck you create when someone creates a "new deck". And then in the "Deck Form", you only change the Deck
properties like name and association.
Or, if you are inlined to do all new elements in the page itself without Ajax and creating new "Slide" objects, you can use the formset
and save the deck and all associated slides.
Post a Comment for "Django: How To Carry Model Form Data From One Page To Another, And Back, Without Commiting To The Db?"