mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Merge pull request #3861 from linovia/feature/relation_get_queryset_override
Refactor the `get_queryset` overriding test
This commit is contained in:
commit
909a3e80a1
|
@ -176,10 +176,12 @@ class TestSlugRelatedField(APISimpleTestCase):
|
||||||
representation = self.field.to_representation(self.instance)
|
representation = self.field.to_representation(self.instance)
|
||||||
assert representation == self.instance.name
|
assert representation == self.instance.name
|
||||||
|
|
||||||
def test_no_queryset_init(self):
|
def test_overriding_get_queryset(self):
|
||||||
|
qs = self.queryset
|
||||||
|
|
||||||
class NoQuerySetSlugRelatedField(serializers.SlugRelatedField):
|
class NoQuerySetSlugRelatedField(serializers.SlugRelatedField):
|
||||||
def get_queryset(this):
|
def get_queryset(self):
|
||||||
return self.queryset
|
return qs
|
||||||
|
|
||||||
field = NoQuerySetSlugRelatedField(slug_field='name')
|
field = NoQuerySetSlugRelatedField(slug_field='name')
|
||||||
field.to_internal_value(self.instance.name)
|
field.to_internal_value(self.instance.name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user