class MySerializer(serializers.Serializer):
    id = serializers.ReadOnlyField()
field1 = serializers.ReadOnlyField()
field2 = serializers.ReadOnlyField()

def to_representation(self, data):
    res = super(MySerializer, self).to_representation(data)
Return list of objects as dictionary with keys as the objects id with django rest framerwork