django-rest-polymorphic icon indicating copy to clipboard operation
django-rest-polymorphic copied to clipboard

Serializing related object

Open gradywoodruff opened this issue 6 years ago • 1 comments

I am attempting to serialize objects from a foreign key, before I made the fk a polymorphic model, this was working for my API

class PostSerializer(serializers.ModelSerializer):
    pictures = PictureSerializer(read_only=True, many=True)
    class Meta:
        model = Post
        fields = '__all__'

but using PicturePolymorphicSerializer instead of PictureSerializer isn't working, is there any way to add the polymorphic serializer as a rest api field?

gradywoodruff avatar Jan 02 '19 03:01 gradywoodruff

@gradywoodruff Were you able to find a solution? Stuck on a similar problem.

djb4ai avatar Dec 03 '20 10:12 djb4ai