A database transaction groups multiple operations so they either all succeed or all fail together (atomicity) — preventing partial, inconsistent updates. Django provides transaction.atomic to wrap operations in a transaction, ensuring data integrity for multi-step operations.
Težava, ki jo rešujejo transakcije
():
from_account.balance -= amount
from_account.save()
to_account.balance += amount
to_account.save()
