[Fixed]-Using nested Django transaction.atomic() to handle exceptions?

1👍

Django triggers rolback only when transaction block catches DatabaseError (or its subclass), So you shouldn’t catch it before it. If you add second transaction block (your 2nd example), error is caught, transaction is marked to rollbacked, and then you can do whatever you want.

I think that you should be good it yo re-raise exactly the same error, but this is just a guess.

Leave a comment