mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Documentation in 'many_init' docstring. Refs #2120.
This commit is contained in:
parent
9c58dfec4e
commit
fd980be39b
|
@ -86,6 +86,15 @@ class BaseSerializer(Field):
|
|||
class when `many=True` is used. You can customize it if you need to
|
||||
control which keyword arguments are passed to the parent, and
|
||||
which are passed to the child.
|
||||
|
||||
Note that we're over-cautious in passing most arguments to both parent
|
||||
and child classes in order to try to cover the general case. If you're
|
||||
overriding this method you'll probably want something much simpler, eg:
|
||||
|
||||
@classmethod
|
||||
def many_init(cls, *args, **kwargs):
|
||||
kwargs['child'] = cls()
|
||||
return CustomListSerializer(*args, **kwargs)
|
||||
"""
|
||||
child_serializer = cls(*args, **kwargs)
|
||||
list_kwargs = {'child': child_serializer}
|
||||
|
|
Loading…
Reference in New Issue
Block a user