Re: Updating a model instance with extra checks.

2012-08-21 Thread Sebastien Flory
all their transactions (credit - >> debit). >> You get lesser performance, but you also get history! >> >> Maybe you could try (not sure about that): >> >> MyModel.objects.filter(money__gte = value, pk = self.pk).update(F...) >> >> and inspect

Updating a model instance with extra checks.

2012-08-20 Thread Sebastien Flory
Hi everyone, I'm looking for the proper django way to do an update of an attribute on my model instance, but only if the attribute current value is checked agains't a condition, in an atomic way, something like this: def use_money(self, value): begin_transaction() real_money = F('money')