Answer the question
In order to leave comments, you need to log in
How to bind saving a model to changing another model?
Good afternoon! There is an Item model . It is necessary that when an instance of the TakenItem model is created for the Item model, a certain number of things are subtracted from the number field (depends on TakenItem ). At first I wanted to implement this using save signals for models, but then I realized that if, for example, Item's number field is already 0, then its subtraction leads to a negative number, which is not correct.
Question: how to make it so that when creating TakenItem'a, if the number field of Item'a is non-zero, then the object is created, and number'athe value was reduced by the one passed in the creation of TakenItem .
Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question