I have the following problem in django.. I have in models.py
class Proposal(models.Model):
#whatever....
credit =models.FloatField(null=True, blank=True)
def save():
#here credit is saved based on some calculation (succesfully)
class Author(models.Model):
#whatever....
balance = models.FloatField(null=True,blank=True)
proposal = models.ManyToManyField(Proposal,null=True,blank=True)
def save(self, force_insert=False, force_update=True):
to_add = sum(self.proposal.all().values_list('credit',flat=True)) # a sum of credits
self.balance = self.balance + to_add # or F(self.balance) + to_add, anyway
try:
super(Author, self).save(force_insert, force_update)
except IntegrityError:
super(Author, self).save(force_insert=True, force_update=False)
So I create an author from admin and from within the author a proposal, i "save" the proposal object, ok, credit succesfully saved, then i save the author, but no balance updated. This happens if only I re-save the author object..
Any suggestions?