Object of type 'Response' has no len() in DRF

Viewed 3712

ive combined two models. one model's field is annotated to another model's so they can merge. However, when I try to return the data, I get TypeError: object of type 'Response' has no len(). I've followed several examples on stackoverflow and it doesnt seem to be working.

Here's what I have:

class ExploreAPIView(generics.ListAPIView):

    def get_queryset(self):
        merged_queryset = Place.get_queryset(self.request.user)
        usr_pks = [u.pk for u in merged_queryset]
        queryset = Place.objects.filter(pk__in=usr_pks)

        serialUser = UserSerializer( User.objects.annotate(time=Extract('date_joined','epoch')), many=True).data[:]
        serialPlace = PlacesSerializer(queryset, many=True).data[:]

        chained_list = sorted(serialPlace +serialUser, key=lambda x: x.get('time'))

        return Response(chained_list)

I dont understand why it returns no len() when it returns items if i print out the chained_list

1 Answers

You're returning a Response from get_queryset. But that method is supposed to return a queryset, as the name implies.

Related