當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。