1👍
✅
It is possible to pass an instance directly to a serializer like this (as specified in the DRF documentation):
from some_app.serializers import FooSerializer
class FooTest(TestCase):
def setUp(self):
self.client = APIClient()
def test_foo_feature(self):
foo_id = generator.generateFoo().id
foo = Foo.objects.get(id=foo_id)
serialized_data = FooSerializer(foo).data
👤Matt
Source:stackexchange.com