Created
July 11, 2012 15:15
-
-
Save matagus/3091068 to your computer and use it in GitHub Desktop.
django transactions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import transaction | |
def manual_rollback(): | |
"""Create and rollback using manual transaction calls""" | |
transaction.enter_transaction_management() | |
transaction.managed() | |
try: | |
try: | |
create() | |
error() | |
except: | |
transaction.rollback() | |
else: | |
transaction.commit() | |
finally: | |
transaction.leave_transaction_management() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment