I don't think that what you are describing is a very good approach to your problem. What I'd do instead is that I'd create a Deposit
Model which would have a ForeignKey
to the account and save the date of the deposit and the amount that was deposited (and probably other information needed).
Now, I'd just add a new Deposit
and then I could get the Balance of the account each time just by summing all the related Deposit
s (and similarly subtracting Withdrawal
s).
Of course there could be other usage cases that would actually need table locking to be sure that rows in a table do not change between SQL statements, however these are database specific and not really related to django. For completeness, I've found a very nice introduction to postgresql table locking here http://www.postgresql.org/docs/9.1/static/explicit-locking.html -- the ACCESS EXCLUSIVE
table-level lock seems to be what'd solve your problem (however I'd double think my design before using things that could lead to deadlocks).