serializers.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:djangocms-rest-view 作者: nephila 项目源码 文件源码
def many_init(cls, *args, **kwargs):
        """
        This method implements the creation of a `ListSerializer` parent
        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)
        """
        kwargs['child'] = BasePageSerializer(*args, **kwargs)
        return ListSerializer(*args, **kwargs)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号