name = models.CharField(max_length=50)
price = models.PositiveIntegerField(default=1)
def __str__(self):
return self.name
class Topping(models.Model):
name = models.CharField(max_length=50)
product_names = models.ManyToManyField(Restaurant, blank=True)
quantity = models.PositiveIntegerField(default=1)
total price of orders , for one product for example : one pizza with one sandwich however they order more than one pizza and sandwich
@property
def total(self):
return self.product_names.aggregate(Sum('price'))['price__sum']
I expected to provide a quantity field for each selected items : pizza : 3 , sandwich:2 , then calculate them (3*pizza price , 2*sandwich price)
thanks for advice
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAKJtO%2Bt3BPPr6m4jkeU0qPR00p5Aoun1h%2Bw7mi%2BYi5jqNf4WoQ%40mail.gmail.com.