当前位置: 首页>>代码示例>>Python>>正文


Python serializer_helpers.ReturnDict方法代码示例

本文整理汇总了Python中rest_framework.utils.serializer_helpers.ReturnDict方法的典型用法代码示例。如果您正苦于以下问题:Python serializer_helpers.ReturnDict方法的具体用法?Python serializer_helpers.ReturnDict怎么用?Python serializer_helpers.ReturnDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rest_framework.utils.serializer_helpers的用法示例。


在下文中一共展示了serializer_helpers.ReturnDict方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_error_details

# 需要导入模块: from rest_framework.utils import serializer_helpers [as 别名]
# 或者: from rest_framework.utils.serializer_helpers import ReturnDict [as 别名]
def _get_error_details(data, default_code=None):
    """
    Descend into a nested data structure, forcing any
    lazy translation strings or strings into `ErrorDetail`.
    """
    if isinstance(data, list):
        ret = [
            _get_error_details(item, default_code) for item in data
        ]
        if isinstance(data, ReturnList):
            return ReturnList(ret, serializer=data.serializer)
        return ret
    elif isinstance(data, dict):
        ret = {
            key: _get_error_details(value, default_code)
            for key, value in data.items()
        }
        if isinstance(data, ReturnDict):
            return ReturnDict(ret, serializer=data.serializer)
        return ret

    text = force_text(data)
    code = getattr(data, 'code', default_code)
    return ErrorDetail(text, code) 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:26,代码来源:exceptions.py

示例2: data

# 需要导入模块: from rest_framework.utils import serializer_helpers [as 别名]
# 或者: from rest_framework.utils.serializer_helpers import ReturnDict [as 别名]
def data(self):
        """Get the data, after performing post-processing if necessary."""
        data = super(DynamicListSerializer, self).data
        processed_data = ReturnDict(
            SideloadingProcessor(self, data).data,
            serializer=self
        ) if self.child.envelope else ReturnList(
            data,
            serializer=self
        )
        processed_data = post_process(processed_data)
        return processed_data 
开发者ID:AltSchool,项目名称:dynamic-rest,代码行数:14,代码来源:serializers.py

示例3: errors

# 需要导入模块: from rest_framework.utils import serializer_helpers [as 别名]
# 或者: from rest_framework.utils.serializer_helpers import ReturnDict [as 别名]
def errors(self):
        ugly_errors = super(FriendlyErrorMessagesMixin, self).errors
        pretty_errors = self.build_pretty_errors(ugly_errors)
        return ReturnDict(pretty_errors, serializer=self) 
开发者ID:FutureMind,项目名称:drf-friendly-errors,代码行数:6,代码来源:mixins.py

示例4: data

# 需要导入模块: from rest_framework.utils import serializer_helpers [as 别名]
# 或者: from rest_framework.utils.serializer_helpers import ReturnDict [as 别名]
def data(self):
        ret = super(serializers.ListSerializer, self).data
        return ReturnDict(ret, serializer=self) 
开发者ID:GetTogetherComm,项目名称:GetTogether,代码行数:5,代码来源:views.py

示例5: data

# 需要导入模块: from rest_framework.utils import serializer_helpers [as 别名]
# 或者: from rest_framework.utils.serializer_helpers import ReturnDict [as 别名]
def data(self):
        ret = super(ListSerializer, self).data
        return ReturnDict(ret, serializer=self) 
开发者ID:bcgov,项目名称:aries-vcr,代码行数:5,代码来源:search.py

示例6: data

# 需要导入模块: from rest_framework.utils import serializer_helpers [as 别名]
# 或者: from rest_framework.utils.serializer_helpers import ReturnDict [as 别名]
def data(self):
    ret = super(ListSerializer, self).data
    return ReturnDict(ret, serializer=self) 
开发者ID:IBM-Blockchain-Identity,项目名称:indy-ssivc-tutorial,代码行数:5,代码来源:search_serializers.py


注:本文中的rest_framework.utils.serializer_helpers.ReturnDict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。