From 1a8f07def8094a1e34a656d83fc7bdba0efff184 Mon Sep 17 00:00:00 2001 From: toran billups Date: Thu, 7 Mar 2013 15:09:59 -0600 Subject: GenericAPIView now applies filter_backend for list and retrieve api views Before this commit only the MultipleObjectAPIView would apply a filter_backend, leaving the SingleObjectAPIView to return objects you might otherwise expect to have been filtered out. It's worth mentioning that when a SingleObjectAPIView makes a request for an object that should be excluded, a 404 is the expected result. --- rest_framework/mixins.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'rest_framework/mixins.py') diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index 97201c4b..8e401204 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -97,7 +97,9 @@ class RetrieveModelMixin(object): Should be mixed in with `SingleObjectAPIView`. """ def retrieve(self, request, *args, **kwargs): - self.object = self.get_object() + queryset = self.get_queryset() + filtered_queryset = self.filter_queryset(queryset) + self.object = self.get_object(filtered_queryset) serializer = self.get_serializer(self.object) return Response(serializer.data) -- cgit v1.2.3