I am trying to get the total but I don't know why I am not getting the total and I have the code of models.py and its output.
class Order(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
items = models.ManyToManyField(OrderItem)
start_date = models.DateTimeField(auto_now_add=True)
table_num = models.CharField(max_length=50)
ordered_date = models.DateTimeField()
ordered = models.BooleanField(default=False)
def __str__(self):
return self.user.username
def total(self):
total = 0
for order_item in self.items.all():
total += order_item.get_total_item_price()
return total

