Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def __iter__(self):
- """
- Перебор элементов в корзине и получение продуктов из базы данных.
- """
- product_ids = self.cart.keys()
- # получение объектов product и добавление их в корзину
- products = Product.objects.filter(id__in=product_ids)
- for product in products:
- self.cart[str(product.id)]['product'] = product
- for item in self.cart.values():
- item['price'] = Decimal(item['price'])
- item['total_price'] = item['price'] * item['quantity']
- yield item
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement