1👍
✅
The reason is that the transaction is marked as dirty on any query in current versions of django (dirty means the connection’s transaction is in progress). Earlier versions of django didn’t mark the transaction as dirty unless data modifyin query was issued – but that was changed as that way was somewhat confusing, and more importantly django has no idea which queries are data modifying when using raw SQL.
The filter() call doesn’t open a transaction as not query is executed at that point.
If you can, use transaction.atomic – it is easy to use and does the right thing in almoust all cases.
Source:stackexchange.com