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