From 7dfc791841134e96b7632eb5902f52bc59bcc414 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Thu, 3 Aug 2017 17:47:40 +0430 Subject: [PATCH] Binding child should happen in bind no init It should fix several issues related to child caching wrong root, the one I was dealing with was that child of a `many=True` serializer didn't have access to context. --- rest_framework/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index a4b51ae9d..2ee566006 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -563,10 +563,10 @@ class ListSerializer(BaseSerializer): assert self.child is not None, '`child` is a required argument.' assert not inspect.isclass(self.child), '`child` has not been instantiated.' super(ListSerializer, self).__init__(*args, **kwargs) - self.child.bind(field_name='', parent=self) def bind(self, field_name, parent): super(ListSerializer, self).bind(field_name, parent) + self.child.bind(field_name='', parent=self) self.partial = self.parent.partial def get_initial(self):