In my view, I am saving data in multiple models:
def myview(request):
#do some processing
model1.save()
model2.save()
How do I ensure that there is a rollback of model1.save()
in case model2.save()
raises an error? Or how do I commit only after both the models are successfully saved?
In other words, "only save model1 and model2 if both save() are successful", or "perform both saves inside a transaction".