Hello everyone, I am attempting to calculate the unit price and quantity from this table using the following model:
class Marketers(models.Model):
category =models.ForeignKey(Category, on_delete=models.CASCADE, null=True)
name =models.CharField(max_length=50, null=True, blank =True)
grade =models.CharField(max_length=50, null=True, blank =True)
quatity_received = models.IntegerField(default=0, null=True, blank =True)
unit_price =models.IntegerField(default=0, null=True, blank =True)
customer = models.CharField(max_length=50, null=True, blank =True)
date_received = models.DateTimeField(auto_now_add=True)
date_sold = models.DateTimeField(auto_now_add=True)
@property
def get_total(self):
total = self.quatity_received * self.unit_price
return total
This is how I call it in my template:
<td class="align-middle text-center">
<span class="text-secondary text-xs font-weight-bold">{{ list.get_total }}</span>
<p class="text-xs text-secondary mb-0">Overall Price </p>
</td>
This is the error I am encountering:
TypeError: unsupported operand type(s) for *: 'NoneType' and 'NoneType'
Could someone please provide assistance? Thank you.