diff options
| author | Tom Christie | 2014-11-25 10:39:58 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-11-25 10:39:58 +0000 |
| commit | fd980be39be7f09d4cf0ceb16688ad0157d4df35 (patch) | |
| tree | fa9b84144370a51028dc4e7f58bed985354946a5 /rest_framework/serializers.py | |
| parent | 9c58dfec4e6865a5296d0913be907a20f712f0d3 (diff) | |
| download | django-rest-framework-fd980be39be7f09d4cf0ceb16688ad0157d4df35.tar.bz2 | |
Documentation in 'many_init' docstring. Refs #2120.
Diffstat (limited to 'rest_framework/serializers.py')
| -rw-r--r-- | rest_framework/serializers.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 2d5c843e..00362dbb 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -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} |
