1👍
✅
Instead of for
loop, use queryset.update with django.db.models.F
:
from django.db.models import F
...
StoreLiquor.objects.filter(storeID=storeID, SPI__gt=LiqSPI).update(SPI=F('SPI')-1)
Source:stackexchange.com