[Answered ]-Mix raw and ORM operations within the same Django transaction?

2👍

Yes, that’s possible.

from django.db import transaction

def viewfunc(request):
    # This code executes in autocommit mode (Django's default).
    do_stuff()

    with transaction.atomic():
        # This code executes inside a transaction.
        do_more_stuff()

Source: https://docs.djangoproject.com/en/1.9/topics/db/transactions/#django.db.transaction.atomic

Leave a comment