class MySerializer(serializers.Serializer):
    id = serializers.ReadOnlyField()
field1 = serializers.ReadOnlyField()
Return list of objects as dictionary with keys as the objects id with django rest framerwork