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 django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to