My model looks like this
class MyModel(models.Model):
end_time = DateTimeField()
and this is what I'm trying to achieve:
m=MyModel.objects.get(pk=1)
m.end_time += timedelta(seconds=34)
m.save()
but I want to do it with update() to avoid race conditions:
MyModel.objects.filter(pk=1).update(end_time=F('end_time')+timedelta(seconds=34))
but it doesn't work. Is this possible with the django ORM or is raw SQL the only option?
This is completely possible. Not sure if you're looking at a cached value for your end_time, but here is a test I just ran: