mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-28 12:34:00 +03:00
Use a resource instance instead of a class to get the queryset
This commit is contained in:
parent
baab2f059f
commit
a632e580e2
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user