Is it possible to get all the values of foreign key instead of id?
class WishlistSerializer(serializers.ModelSerializer):
def to_representation(self, instance):
rep = super(WishlistSerializer, self).to_representation(instance)
rep['product'] = instance.product.name
return rep
Assuming you have a model structure like this:
Your Updated serializer :
By creating a product_name field in your serializer and using the source parameter to specify the attribute path (product.name), you can retrieve the name attribute of the related product and include it in the representation of the Wishlist model. This way, you will get the product name instead of the product ID in the serialized output.