Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. class Product(models.Model):
  2. name = models.CharField(max_length=255)
  3. price = models.DecimalField(decimal_places=2, max_digits=12)
  4. store = models.ForeignKey(Store)
  5.  
  6. class Variation(models.Model):
  7. product = models.ForeignKey(Product)
  8. title = models.CharField(max_length=255)
  9. active = models.BooleanField(default=True)
  10. stock = models.PositiveIntegerField(null=True, blank=True)
  11. deleted = models.BooleanField(default=False)
  12.  
  13. class Orderitem(models.Model):
  14. variation = models.ForeignKey(Variation)
  15. quantity = models.PositiveIntegerField() # I want to display the sum of this
  16. order = models.ForeignKey(Order)
  17.  
  18. class Product(models.Model):
  19. ...
  20.  
  21. def get_total_order(self):
  22. return ...
  23.  
  24. {{ product.get_total_order }}
  25.  
  26. def your_view(request, ...):
  27. return render(request, template_name...html, {'total_order': xxx})
  28.  
  29. {{ total_order }}
  30.  
  31. {{ product|product_total_order }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement