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
You're returning a Response from get_queryset
. But that method is supposed to return a queryset, as the name implies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With