diff --git a/app/models.py b/app/models.py index 5bec32f..9db3526 100644 --- a/app/models.py +++ b/app/models.py @@ -110,6 +110,12 @@ class Order(db.Model): return group + def len(self): + size = 0 + for _ in self.items: + size = size + 1 + return size + def group_by_product(self): group = dict() for item in self.items: diff --git a/app/templates/order.html b/app/templates/order.html index a0064b2..4ee0619 100644 --- a/app/templates/order.html +++ b/app/templates/order.html @@ -78,7 +78,7 @@
-

Ordered products: {% len(order.items) %}

+

Ordered products: {{ order.len() }}

{% for key, value in order.group_by_product().items() -%}
{{ key }}: {{ value["count"] }}