[Answered ]-Django Rest – Include serializer object in get_*** method

2👍

✅

There is no need for the get_included method. Simply add the snippets attribute to the class.

class UserSerializer(serializers.ModelSerializer):
    included = SnippetSerializer(many=True, read_only=True)

    class Meta: 
        model = User
        depth = 1 
        fields = ('id','included')

Leave a comment