generate update query using django orm
Both the previous answerers have part of the solution: you should use update
in conjunction with F()
:
Model.objects.filter(id=id).update(field=F('field') +1))
Note this does an in-place UPDATE without any need for SELECT at all.
You can use update
, details can be found in the documentation