Thanks, I'll try the print statements. This is my first pass at the save() routine, and your idea is good, although I may try other methods.
Thanks for the help. John On Jan 25, 11:01 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > On Jan 25, 1:39 pm, John M <[EMAIL PROTECTED]> wrote: > > > Well, it is in my file, and I can thank Windows for the bad paste :). > > Ah.. > > > Assume the indenting is right, any other thoughts? > > How are you saving the Trade object when you say it doesn't work? Is > that through the Admin or through your own view and form? > > Consider adding a few print statements in Trade.save() to see why > h.save() might not be getting called. > > Also, this is not relevant to the problem above, but you have > "h.shares += self.shares" on line 89. That would mean that whenever > trade.save() is called, holding.shares keeps going up by the quantity > trade.shares. I would create a method called say "recompute" in > Holding and have it refresh its count. Something like: > > def recompute(self): > shares = 0 > for t in Trade.objects.filter(holding=self): > shares += t.shares > self.shares = shares > super(Holding, self).save() > > Then, at the end of Trade.save(), just call self.holding.recompute(). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

