test varients response
This commit is contained in:
@@ -116,7 +116,10 @@ class DynamicProductSerializer(serializers.ModelSerializer):
|
||||
}
|
||||
|
||||
def get_variants(self, obj):
|
||||
return ProductVariantSerialzier(instance=obj.variants.all(), many=True, context=self.context).data
|
||||
varients = obj.variants.all()
|
||||
colors = set(varient.color for varient in varients)
|
||||
response = {color: ProductVariantSerialzier(instance=varients.filter(color=color), many=True, context=self.context).data for color in colors}
|
||||
return response
|
||||
|
||||
# def get_variants_colors(self, obj):
|
||||
# varients = obj.variants.all()
|
||||
@@ -149,3 +152,4 @@ class CommentSerializer(serializers.ModelSerializer):
|
||||
exclude = ('review_status', )
|
||||
read_only_fields = ('review_status', 'product', 'user')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user