def list(self, request, *args, **kwargs): queryset = self.filter_queryset(self.get_queryset()) page = self.paginate_queryset(queryset) if page is not None: serializer = self.get_serializer(page, many=True) data = get_serializer_data_to_json(serializer.data) data = clean_response_field(data, self.del_fields) return self.get_paginated_response(data) serializer = self.get_serializer(queryset, many=True) data = get_serializer_data_to_json(serializer.data) data = clean_response_field(data, self.del_fields) return CustomBaseJsonResponse(data)
def retrieve(self, request, *args, **kwargs): instance = self.get_object() serializer = self.get_serializer(instance) data = get_serializer_data_to_json(serializer.data) data = clean_response_field(data, self.del_fields) return CustomBaseJsonResponse(data=data, code=status.HTTP_200_OK, msg="Queried successfully.", status=True)