3👍
✅
You can do this by overriding the list
method of the ListAPIView
and then adding this new field to the response:
from rest_framework.response import Response
def list(self, request, *args, **kwargs):
queryset = self.get_queryset()
serializer = self.get_serializer(queryset, many=True)
response_data = {'custom_field': 'custom value',
'result': serializer.data}
return Response(response_data)
Source:stackexchange.com