Skip to content

Instantly share code, notes, and snippets.

@carljm
Last active June 16, 2016 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carljm/5a0ccc6a821cc182927ef68781cadbcd to your computer and use it in GitHub Desktop.
Save carljm/5a0ccc6a821cc182927ef68781cadbcd to your computer and use it in GitHub Desktop.
class TransactionMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
with transaction.atomic():
response = self.get_response(request)
if response.status_code == 500:
transaction.set_rollback()
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment