hi there, i'm working on an restaurant ordering system , when someone order
more than one product with different quantities for each product , be able
to select its quantities
it may order 3 Pizza with 2 sandwich , how to let the customer to define
the quantities of each product , and then calculate with its prices
class Restaurant(models.Model):
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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/227bb8d8-f393-43d0-a9a8-79557f0e32df%40googlegroups.com.