Today in django database data processing, the use affairs, could not stand the official documentation, online information, called a needle in a haystack, ah, I can not find their desired effect.
django of affairs,
Django1.6 based document, "Django provides a simple API to control transactional database transaction ... atomic operation is used to define a database transaction.
Atomic operations allow us to ensure that the database under the premise of creating a bunch of code. If the code is successfully performed, the corresponding changes are committed to the database. If an exception occurs, the operation will be rolled back. "
May be employed decorator usage or usage code block, code block strongly recommended, as follows.
from django.db import transaction
def index(request):
try:
with transaction.atomic():
work2()
except Exception:
pass
If you do not put in an exception try to automatically submit the transaction, abnormal automatic rollback