some edit on product stat serializer
This commit is contained in:
@@ -35,6 +35,18 @@ class ProductStatsSerializer(serializers.ModelSerializer):
|
|||||||
model = product_models.ProductStats
|
model = product_models.ProductStats
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def to_representation(self, instance):
|
||||||
|
""" custom output of product stat """
|
||||||
|
|
||||||
|
representation = super().to_representation(instance)
|
||||||
|
|
||||||
|
representation['product'] = {
|
||||||
|
'id': instance.product.id,
|
||||||
|
'name': instance.product.name
|
||||||
|
}
|
||||||
|
|
||||||
|
return representation
|
||||||
|
|
||||||
|
|
||||||
class AttributeSerializer(serializers.ModelSerializer):
|
class AttributeSerializer(serializers.ModelSerializer):
|
||||||
""" serialize attributes of reference product """
|
""" serialize attributes of reference product """
|
||||||
|
|||||||
Reference in New Issue
Block a user