I have an admin action that looks like this:
def process(modeladmin, request, queryset):
for reservation in queryset:
if not reservation.processed:
reservation.processed = True
reservation.save()
item = reservation.item
item.available = F('available') - reservation.quantity
item.save()
So, the administrator can handle it reservation item. Whenever he does this, it is reservationmarked as processed, and the number of available is itemsreduced by the amount indicated in reservation.
As this happens for all administrator actions, the administrator can process several reservationsat a time. Everything goes well, if it reservationsis all different items. But if two reservationsare separated by one item, the number of available is itemsreduced only by the amount indicated in the last processed reservation.
, F() : item item . ?