sending the real image for product list the 3 first one
This commit is contained in:
@@ -24,4 +24,9 @@ class OrderSerializer(serializers.ModelSerializer):
|
|||||||
def get_count(self, obj):
|
def get_count(self, obj):
|
||||||
return obj.items.all().count()
|
return obj.items.all().count()
|
||||||
def get_images(self, obj):
|
def get_images(self, obj):
|
||||||
return ["a" , "b" , "c"]
|
image_list = [
|
||||||
|
self.context.get('request').build_absolute_uri(image.image.url)
|
||||||
|
if (image := item.product.images.all().first()) else None
|
||||||
|
for item in obj.items.all()[:3]
|
||||||
|
]
|
||||||
|
return filter(lambda x: x is not None, image_list)
|
||||||
Reference in New Issue
Block a user