aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/mixins.py
diff options
context:
space:
mode:
authortoran billups2013-03-07 15:09:59 -0600
committertoran billups2013-03-08 10:08:53 -0600
commit1a8f07def8094a1e34a656d83fc7bdba0efff184 (patch)
tree2b6a3cf0f336b1723d6bd74e773b6ad56dca6cf6 /rest_framework/mixins.py
parent4e80541824bab0712a816716c5c63ec5623370d8 (diff)
downloaddjango-rest-framework-1a8f07def8094a1e34a656d83fc7bdba0efff184.tar.bz2
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.
Diffstat (limited to 'rest_framework/mixins.py')
-rw-r--r--rest_framework/mixins.py4
1 files changed, 3 insertions, 1 deletions
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)