mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +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)
|
||||
assert representation == self.instance.name
|
||||
|
||||
def test_no_queryset_init(self):
|
||||
def test_overriding_get_queryset(self):
|
||||
qs = self.queryset
|
||||
|
||||
class NoQuerySetSlugRelatedField(serializers.SlugRelatedField):
|
||||
def get_queryset(this):
|
||||
return self.queryset
|
||||
def get_queryset(self):
|
||||
return qs
|
||||
|
||||
field = NoQuerySetSlugRelatedField(slug_field='name')
|
||||
field.to_internal_value(self.instance.name)
|
||||
|
|
Loading…
Reference in New Issue
Block a user