The Django documentation states that:
If you were relying on “automatic transactions” to provide locking between select_for_update() and a subsequen
select_for_update
will only lock the selected row within the context of a single transaction. If you're using autocommit, it won't do what you think it does, because each query will effectively be its own transaction (including the SELECT ... FOR UPDATE
query). Wrap your view (or other function) in transaction.atomic
and it'll do exactly what you're expecting it to do.