Django unable to update model

Posted by user292652 on Stack Overflow See other posts from Stack Overflow or by user292652
Published on 2010-03-13T06:40:57Z Indexed on 2010/03/13 6:45 UTC
Read the original article Hit count: 450

i have the following function to override the default save function in a model match

def save(self, *args, **kwargs):
   if self.Match_Status == "F":
        Team.objects.filter(pk=self.Team_one.id).update(Played=F('Played')+1)
        Team.objects.filter(pk=self.Team_two.id).update(Played=F('Played')+1)
        if self.Winner !="":   
          Team.objects.filter(pk=self.Winner.id).update(Win=F('Win')+1, Points=F('Points')+3)
        else:
            return
   if self.Match_Status == "D":
        Team.objects.filter(pk=self.Team_one.id).update(Played=F('Played')+1, Draw = F('Draw')+1, Points=F('Points')+1)
      Team.objects.filter(pk=self.Team_two.id).update(Played=F('Played')+1, Draw = F('Draw')+1, Points=F('Points')+1)
   super(Match, self).save(*args, **kwargs)

I am able to save the match model just fine but Team model does not seem to be updating at all and no error is being thrown. am i missing some thing here ?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models