Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django example of a form that submits multiple instances into a database?

I need a django form that submits multiple separate requests, and can't find an example of how to do this without a lot of customization. I.e., suppose there is a form that is used by a car repair shop. The form will list all the possible repairs that the shop is capable of doing, and the user will select which repairs they want to have done (i.e., using checkboes.)

Each repair can be assigned to a different mechanic. Each repair can also be cancelled or declared to be done, independent of the other repairs. That seems to require that each repair become a separate instance in a database.

Additionally, each repair job can be only performed by certain mechanic. So I need the ability to associate each repair job to it's own unique list of mechanics to choose from.

Has anyone seen an example of a django form, that does something like this? Thanks.

like image 355
user1993015 Avatar asked Nov 03 '22 05:11

user1993015


1 Answers

This is what formsets (and model formsets) are for.

like image 143
Daniel Roseman Avatar answered Nov 15 '22 07:11

Daniel Roseman