On Sun, 2009-01-11 at 01:53 -0800, Matt Welch wrote: > I appreciate it. Thank you. > > I tried the examples you said and ran into one problem on the first > ( happened in the second, but fixed ). > > On Jan 11, 3:12 am, Malcolm Tredinnick <malc...@pointy-stick.com> > wrote: > > On Sun, 2009-01-11 at 00:11 -0800, juice wrote: > > > > > I then figured it may run into a loop of saving the same model, so i > > > > > was going to use signals but ran into the same issue that it would > > > > > still need to be in the save function. > > > > > > Are you talking about the infinite loop problem here? I don't understand > > > > this paragraph. > > > > > Yes sir, after talking with webology, he also pointed out it would end > > > up in an infinite loop. So i went looking into signals. > > > > I think you may have thrown out the baby with the bathwater there. All > > you should have to do is check if the location you retrieve is the same > > as the current one and, if so, don't do the update. Like this: > > > > def save(self, *args, **kwargs): > > oa = Article.objects.filter(location=self.location) > > if oa and oa[0] != self: > > oa = oa(location=0) > > oa.save() > > super(Article, self).save(*args, **kwargs) > > > > This returned 'QuerySet' object is not callable, so i changed > Article.objects.filter -> Article._default_manager.filter(....), still > returning the same problem with the update.
Oh. This is because I'm an idiot and wasn't concentrating. The lines oa = oa(location=0) oa.save() are bogus. "oa" is a queryset, not an object. It should be obj = oa[0] obj.location = 0 obj.save() Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---