from django.db import transaction

def viewfunc(request):
    do_stuff()
with transaction.atomic():
    do_more_stuff()
How to force django to save immediately instead of doing a batch update after loop