class BloggerInfoSerializer(serializers.ModelSerializer): socials = MaterialSocialSerializer(many=True) masters = MaterialMasterSerializer(many=True) class Meta: model = BloggerInfo fields = "__all__"
class BloggerInfoSerializer(serializers.ModelSerializer): socials = MaterialSocialSerializer(many=True) masters = MaterialMasterSerializer(many=True) avatar = serializers.SerializerMethodField() background = serializers.SerializerMethodField() def get_avatar(self, blogger_info): if blogger_info.avatar: return "{0}/{1}".format(MEDIA_URL_PREFIX, blogger_info.avatar) def get_background(self, blogger_info): if blogger_info.background: return "{0}/{1}".format(MEDIA_URL_PREFIX, blogger_info.background) class Meta: model = BloggerInfo fields = "__all__"