當前位置: 首頁>>代碼示例>>Python>>正文


Python serializers.DictField方法代碼示例

本文整理匯總了Python中rest_framework.serializers.DictField方法的典型用法代碼示例。如果您正苦於以下問題:Python serializers.DictField方法的具體用法?Python serializers.DictField怎麽用?Python serializers.DictField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rest_framework.serializers的用法示例。


在下文中一共展示了serializers.DictField方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _writable_fields

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import DictField [as 別名]
def _writable_fields(self) -> List:
        writable_fields = super(_SignalSerializer, self)._writable_fields
        fields = []
        attrs = [
            'field_name', 'source_attrs', 'source',
            'read_only', 'required', 'write_only', 'default'
        ]
        for field in writable_fields:
            if not isinstance(field, DataSerializer):
                fields.append(field)
                continue
            field_object = serializers.DictField()
            for attr in attrs:
                setattr(field_object, attr, getattr(field, attr, None))
            fields.append(field_object)
        return fields 
開發者ID:vstconsulting,項目名稱:polemarch,代碼行數:18,代碼來源:serializers.py

示例2: get_fields

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import DictField [as 別名]
def get_fields(self):
        query_facet_counts = self.instance.pop('queries', {})

        field_mapping = super(BaseHaystackFacetSerializer, self).get_fields()

        query_data = self.format_query_facet_data(query_facet_counts)

        field_mapping['queries'] = DictField(query_data, child=QueryFacetFieldSerializer(), required=False)

        if self.serialize_objects:
            field_mapping.move_to_end('objects')

        self.instance['queries'] = query_data

        return field_mapping 
開發者ID:edx,項目名稱:course-discovery,代碼行數:17,代碼來源:serializers.py

示例3: fallback_schema_from_field

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import DictField [as 別名]
def fallback_schema_from_field(self, field):
        """ Fallback schema for field that isn't inspected properly by DRF
        and probably won't land in upstream canon due to its hacky nature only for doc purposes
        """
        title = force_text(field.label) if field.label else ''
        description = force_text(field.help_text) if field.help_text else ''

        # since we can't really inspect dictfield and jsonfield, at least display object as type
        # instead of string
        if isinstance(field, (serializers.DictField, serializers.JSONField)):
            return coreschema.Object(
                properties={},
                title=title,
                description=description
            ) 
開發者ID:limdauto,項目名稱:drf_openapi,代碼行數:17,代碼來源:entities.py

示例4: test_should_dict_convert_dict

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import DictField [as 別名]
def test_should_dict_convert_dict():
    assert_conversion(serializers.DictField, DictType) 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:4,代碼來源:test_field_converter.py

示例5: __init__

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import DictField [as 別名]
def __init__(self, *args, **kwargs):
        self.allow_empty = kwargs.pop('allow_empty', True)
        super(DictField, self).__init__(*args, **kwargs) 
開發者ID:umutbozkurt,項目名稱:django-rest-framework-mongoengine,代碼行數:5,代碼來源:fields.py


注:本文中的rest_framework.serializers.DictField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。