8👍
✅
Apparently, the docs say that you would need to write the filtering yourself for ListAPIView
.
See also this similar question.
In your case, that would look like this:
class ListPostsOfReddit(ListAPIView):
serializer_class = PostSerializer
def get_queryset(self):
return Post.objects.filter(subreddit__id=self.kwargs['r_id'])
As far as I understand the docs for the generic API views, the lookup_field
and lookup_url_kwarg
attributes are used only in the detail views, not the list views.
👤Ralf
Source:stackexchange.com