I have two threads, one which runs something like update t set ColA=foo
and the other runs update t set ColB=foo
. If they were doing raw SQL statements there would be no contention, but since Django gets and saves the entire row, a race condition can occur.
Is there any way to tell Django that I just want to save a certain column?
Update old topic.
Now, we have update_fields argument with save:
If save() is passed a list of field names in keyword argument update_fields, only the fields named in that list will be updated.
https://docs.djangoproject.com/en/stable/ref/models/instances/#specifying-which-fields-to-save
product.name = 'Name changed again'
product.save(update_fields=['name'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With