An example of a Django form that represents multiple instances in a database?

I need a django form that represents several separate requests and cannot find an example of how to do this without a lot of customization. Suppose there is a form used by a car repair shop. The form will list all the possible repairs that the store can do, and the user will choose which repairs they want to do (that is, use the control panels.)

Each repair can be assigned to a different mechanic. Each repair can also be canceled or declared completed, regardless of other repairs. Each repair seems to be a separate instance in the database.

In addition, each repair task can only be performed by a specific mechanic. Therefore, I need the opportunity to associate each repair job with its own unique list of mechanics to choose from.

Has anyone seen an example of a django form, something like this? Thank.

+5
source share
2 answers

Here is what formsets (and model models ) are for.

+2
source

Some time passed from the question, and I had the same problem:

I solved it with instance = form.save (commit = False), then set different attributes, then instance.save (force_insert = True), and then deleted form.instance.id ....

HOWEVER, , , , frist ()... !

?

0

All Articles