Last active
June 16, 2016 08:33
-
-
Save carljm/5a0ccc6a821cc182927ef68781cadbcd to your computer and use it in GitHub Desktop.
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
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