Z
Z
zkweb2015-10-12 17:22:19
Django
zkweb, 2015-10-12 17:22:19

How to set a condition for m2m_changed to be executed?

Tell me, please, how can I do the following:
Models: Service, Request, Rzi, RziRequest
In the Service model - there are contracts
In the Request model - there are calls under contracts
In Rzi, RziRequest - in fact, everything is the same as above.
The Rzi model has a contract number field ,

  • - if it is filled (i.e. there is a contract number), then all values ​​selected in ManyToManyField must be written to another intermediate table Service_Request
  • - otherwise write everything to the intermediate table Rzi_RziRequest

Now all the selected data from the ManyToManyField is written to the intermediate table Rzi_RziRequest
How can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-10-12
@sim3x

It is enough to make a method for the model, from which to return bool if

there is a contract number field,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question