Django深入----django.db.transaction
django 的事务:
transaction.py
atomic---原子性
def atomic(using=None, savepoint=True): # Bare decorator: @atomic -- although the first argument is called # `using`, it's actually the function being decorated. if callable(using): return Atomic(DEFAULT_DB_ALIAS, savepoint)(using) # Decorator: @atomic(...) or context manager: with atomic(...): ... else: return Atomic(using, savepoint)
调用:
@tx.atomic @model_pk_lock def update(self, request, *args, **kwargs):