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

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -