Hello, I am trying to calculate fields directly from a model but no luck. I want to get total_price from quantity, reoder_level and unit price. My code is abelow, Please advise.
class Stock(models.Model): unit_price = models.DecimalField(max_digits=10, decimal_places=2, default='0', blank=True, null=True) quantity = models.IntegerField(default='0', blank=True, null=True) total_price = models.DecimalField(max_digits=10, decimal_places=2,default=1) reorder_level = models.IntegerField(default='0', blank=True, null=True) def save(self, *args, **kwargs): self.total_price = self.quantity + self.reorder_level * self.unit_price super(Stock, self).save(*args, **kwargs) What am i my doing wrong Regards, -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADYG20HBcMMGq6QodO0v%2BeZVmfS%2Bmr4aCSro5FZeeRLFdQztnQ%40mail.gmail.com.