I want to increment the value in the database without having to perform a hit on the db to find the actual value. Effectively, I would like to do something like this… but this does not work. Any elegant solutions?
P.objects.filter(username='John Smith').update(accvalue+=-50)
THANKS!
Check out Django’s F() object.
You can combine it with
update()method to update the value based on the previos field value i.e.This will use database’s native
UPDATEmethod to do what you want to do.