Relative Content

Tag Archive for pythondjangosessiondjango-modelscart

why recognize my models in an other app in django how can i call models in other app

from product.models import Product CART_SESSION_ID = ‘cart’ class Cart: def __init__(self, request): self.session = request.session cart = self.session.get(CART_SESSION_ID) if not cart: cart = self.session[CART_SESSION_ID] = {} self.cart = cart def __iter__(self): cart = self.cart.copy() for item in cart.values(): item[‘product’] = Product.objects.get(id=int(item[‘id’])) item[‘total’] = int(item[‘price’]) * int(item[‘quantity’]) yield item def unique_id_generator(self, id, color, size): result = […]