Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Product(models.Model):
- name = models.CharField(max_length=255)
- price = models.DecimalField(decimal_places=2, max_digits=12)
- store = models.ForeignKey(Store)
- class Variation(models.Model):
- product = models.ForeignKey(Product)
- title = models.CharField(max_length=255)
- active = models.BooleanField(default=True)
- stock = models.PositiveIntegerField(null=True, blank=True)
- deleted = models.BooleanField(default=False)
- class Orderitem(models.Model):
- variation = models.ForeignKey(Variation)
- quantity = models.PositiveIntegerField() # I want to display the sum of this
- order = models.ForeignKey(Order)
- class Product(models.Model):
- ...
- def get_total_order(self):
- return ...
- {{ product.get_total_order }}
- def your_view(request, ...):
- return render(request, template_name...html, {'total_order': xxx})
- {{ total_order }}
- {{ product|product_total_order }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement