from django.db import transaction
entries = Entry.objects.select_for_update().filter(author=request.user)
with transaction.atomic():
for entry in entries:
...
At the same time, below in the description it says that:
Evaluating a queryset with select_for_update()
in autocommit mode on
backends which support SELECT ... FOR UPDATE
is a
TransactionManagementError
error because the
rows are not locked in that case.
Does this mean that the above code example will raise TransactionManagementError
, since the select_for_update_query is evaluated outside atomic block?
(I have'nt actually tried this out yet, will soon. I think may be a correction is required in the code example)