From a632e580e255abce6a10c89551f28ee00cc1609f Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Poe Date: Wed, 29 Aug 2012 17:58:44 -0400 Subject: [PATCH] Use a resource instance instead of a class to get the queryset --- djangorestframework/mixins.py | 4 ++-- djangorestframework/tests/mixins.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/djangorestframework/mixins.py b/djangorestframework/mixins.py index 34e9b92b3..d910e0c93 100644 --- a/djangorestframework/mixins.py +++ b/djangorestframework/mixins.py @@ -514,8 +514,8 @@ class ModelMixin(object): """ Return the queryset for this view. """ - return getattr(self.resource, 'queryset', - self.resource.model.objects.all()) + return getattr(self._resource, 'queryset', + self._resource.model.objects.all()) def get_ordering(self): """ diff --git a/djangorestframework/tests/mixins.py b/djangorestframework/tests/mixins.py index 8268fdca7..d83692553 100644 --- a/djangorestframework/tests/mixins.py +++ b/djangorestframework/tests/mixins.py @@ -29,6 +29,7 @@ class TestModelRead(TestModelsTestCase): request = self.req.get('/groups') mixin = ReadModelMixin() mixin.resource = GroupResource + mixin._resource = GroupResource(mixin) response = mixin.get(request, id=group.id) self.assertEquals(group.name, response.name) @@ -40,6 +41,7 @@ class TestModelRead(TestModelsTestCase): request = self.req.get('/groups') mixin = ReadModelMixin() mixin.resource = GroupResource + mixin._resource = GroupResource(mixin) self.assertRaises(ErrorResponse, mixin.get, request, id=12345)