Skip to content

Commit fd980be

Browse files
committed
Documentation in 'many_init' docstring. Refs #2120.
1 parent 9c58dfe commit fd980be

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

rest_framework/serializers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ def many_init(cls, *args, **kwargs):
8686
class when `many=True` is used. You can customize it if you need to
8787
control which keyword arguments are passed to the parent, and
8888
which are passed to the child.
89+
90+
Note that we're over-cautious in passing most arguments to both parent
91+
and child classes in order to try to cover the general case. If you're
92+
overriding this method you'll probably want something much simpler, eg:
93+
94+
@classmethod
95+
def many_init(cls, *args, **kwargs):
96+
kwargs['child'] = cls()
97+
return CustomListSerializer(*args, **kwargs)
8998
"""
9099
child_serializer = cls(*args, **kwargs)
91100
list_kwargs = {'child': child_serializer}

0 commit comments

Comments
 (0)