Yes. self.bar += c self.save()
Isn't "self" refers to existing object? On 21 Wrz, 16:18, phoebebright <phoebebri...@spamcop.net> wrote: > The code looks like it only handles the case of adding a new foo > object but your comments refer to "old values". Are you also > expecting this to work for an update? > > On Sep 21, 7:35 am, Szymon <szy...@mwg.pl> wrote: > > > > > Hello, > > > I have strange problem. I will give example. I have model: > > > class foo(models.Model) > > bar = models.IntegerField() > > > and method in it > > > def add_bar(c): > > from something.models import bar_log > > b = bar_log(foo=self, cnt=c) > > b.save() > > self.bar += c > > self.save() > > > ... and now the problem. Sometimes "bar" in "foo" doesn't get updated. > > There is record in bar_log, but "bar" in "foo" have old value. How can > > I trace problem? There are no exceptions at all. > > > I'm using Django 1.1, Postgresql with psycopg2 as interface. There are > > two parts of my application - web interface and daemonized part that > > runs some background tasks every 5 seconds. > > > Best regards, > > Szymon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---