I have requirement to show the total record count together with response data in django-restframework. I manage to add the status but not the total record count as below
{ "status": "success", "data": [ { ... }, { ... } ] }
Expected result should be { "status": "success", "data": [ { ... }, { ... } ] }
views.py
class MyView(APIView): serializer_class = MySerializers
def get(self, request, format=None):
rs = MyModel.objects.filter(segment_column_name='SEGMENT1')
serializer = MySerializers(rs, many=True)
return Response({"status": "success", "data": serializer.data}, status=status.HTTP_200_OK)
Many thanks in advance, efends