On Sep 7, 9:02 am, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > The SQL "update" statement is atomic (well, it's supposed to be at > least), so queryset.update should solve the problem (nb : not tested): > > YourModel.objects.filter( > pk=object.pk, > expiration_datetime < datetime.datetime.now() > ).update( > counter== F('counter') + 1, > expiration_datetime = F('expiration_datetime') + > datetime.timedelta(days=1) > ) > > HTH
I was going to reply to this question with a similar proposal (note you can't use "<" in a filter, it should be "__lt=") but it turns out that F() doesn't work with anything other than strings or ints - dates are out. (There doesn't seem to be any technical reason why this should be, and I have been trying to work up a patch, but it's a very complicated bit of code.) I think raw SQL is the only way to solve this problem for now. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.