python - If statement in Django not working in properly -


i have small project , have been unable following statement work. great. user inputs can either self.sale_head $ value,if $ value not add self.estimated_weight_hd used total weight, code below should return estimated_weight_total can used total sale price. works when add estimated_weight_total manually. lost why.

def calc_estimated_weight_total(self):     if self.sale_head <= 0:         amount = (self.number * self.estimated_weight_hd)         return amount  def save(self):     self.estimated_total_weight = self.calc_estimated_weight_total()     super(salenote, self).save() 

your code doesn't want cause if self.sale_head > 0 nothing return. description, think code should somthing like:

def calc_estimated_weight_total(self):     if self.sale_head <= 0:         amount = (self.number * self.estimated_weight_hd)         return amount     else:         return something_only_you_know  def save(self):     self.estimated_total_weight = self.calc_estimated_weight_total()     super(salenote, self).save() 

Comments

Popular posts from this blog

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

Change the color of an oval at click in Java AWT -