> > 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. So with the help there and here, i moved onto signals.py. By trial and error, I hope to get going, but have run into a roadblock. If in the signals.py I put "from stories.models import Article", i receive ImportError: cannot import name Article. Now my reasoning behind this maybe wrong as well, so a little explanation there. I want to import the model so I can do my query on all objects to find the previous one with the old location...( or I think that is how I should handle it) thanks again matt On Jan 11, 1:21 am, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Sat, 2009-01-10 at 22:26 -0800, juice wrote: > > I am having trouble with setting up a pre_save signal. I want to be > > able to set a location in a model instance, but only have 1 entry at > > any time. I thought about just overriding the save, and adding an > > update something like: > > > def save(sefl): > > oa = Article.objects.filter(location=self.location) > > oa = oa[0] > > oa = oa(location=0) > > oa.save() > > super.save() > > > Something so that it will find the old object with that location, set > > it to 0, then continue with the new updated one. This is having > > problems on the queryset operations. > > Define "problems". It did nothing? It raised an exception? Your computer > caught on fire? It will use understand what the underlying issue is. > > One thing that does jump out is you'll almost certainly need to handle > the oa == self case, since that will infinitely loop, by the looks of it > (once you fix the various syntax errors in the above). > > > 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. > > 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 -~----------~----~----~----~------~----~------~--~---