Hello, guys tl; dr: Is there a way to make [save + post_save] and [delete + post_delete] operations atomic? That is, if the operations in the function triggered by the post_save signal fail, then the save itself is reverted?
Long version: I have a certain model MyModel and I keep track of changes in a certain field MyModel.my_field with another model, let's call it MyFieldHistory. I create a new MyFieldHistory item if the field changes in the main model, but I must also be able to change the history of an object in case mistakes are made, and if history changes and the latest element is different from the current value, I update the MyModel object. That creates a bit of a loop in which a change in MyModel triggers a change in MyFieldHistory, which is turns triggers a change in MyModel. I am currently doing this in a assymetrical way: MyModel.save() has been customized to check whether the field history latest item is the same as the current value in the model. If not, it creates a new item in the history, with the current datetime and MyModel.my_field value. I made it atomic to make sure the update fails if for any reason the history item cannot be created. I created a function which also checks whether the field history latest item is the same as the current value in the model, but enforces the history data over the MyModel instance - that is, if they differ, the MyModel instance is changed rather than the history. I made it with a function so that I can use it both with post_save and post_delete signals, but I would like to make sure that if this function fails, the change in the history will be reverted, almost like an integrity guarantee. Is that possible? Or should I be doing this some other way? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMpbhxyE9ONTt8raYM3U2bPC-8OgGjY0d_YLyhj%3DiZtc98XP%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

