def get(self, request): cart = Cart(request) offer_id = request.GET.get('offer_id') quantity = request.GET.get('quantity', 1) offer = get_object_or_404(Offer, pk=offer_id) cart.change_quantity(offer.id, int(quantity)) return redirect('cart')
def get(request): product_id = request.GET.get('product_id') quantity = int(request.GET.get('quantity')) cart = Cart(request) cart.change_quantity(product_id, quantity) cost = '{:,}'.format(cart.cart[product_id]['cost']).replace(',', ' ') context = { 'cart_len': len(cart), 'cost': cost, } return JsonResponse(context)