def get(self, request): last_products_id = request.session.get('last_products', []) if not len(last_products_id): return Response([]) products = Product.get_last_products(last_products_id) return Response(ProductSerializer(products, many=True).data)
def get_last_products(session): last_products_id = session.get('last_products', []) if not len(last_products_id): return [] return Product.get_last_products(last_products_id)