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


Python fields.Field方法代码示例

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


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

示例1: __init__

# 需要导入模块: from rest_framework import fields [as 别名]
# 或者: from rest_framework.fields import Field [as 别名]
def __init__(
        self,
        requires=None,
        deferred=None,
        field_type=None,
        immutable=False,
        **kwargs
    ):
        """
        Arguments:
            deferred: Whether or not this field is deferred.
                Deferred fields are not included in the response,
                unless explicitly requested.
            field_type: Field data type, if not inferrable from model.
            requires: List of fields that this field depends on.
                Processed by the view layer during queryset build time.
        """
        self.requires = requires
        self.deferred = deferred
        self.field_type = field_type
        self.immutable = immutable
        self.kwargs = kwargs
        super(DynamicField, self).__init__(**kwargs) 
开发者ID:AltSchool,项目名称:dynamic-rest,代码行数:25,代码来源:fields.py

示例2: mongo_field_repr

# 需要导入模块: from rest_framework import fields [as 别名]
# 或者: from rest_framework.fields import Field [as 别名]
def mongo_field_repr(value):
    # mimic django models.Field.__repr__
    path = '%s.%s' % (value.__class__.__module__, value.__class__.__name__)
    name = getattr(value, 'name', None)
    if name is not None:
        return '<%s: %s>' % (path, name)
    return '<%s>' % path 
开发者ID:umutbozkurt,项目名称:django-rest-framework-mongoengine,代码行数:9,代码来源:repr.py

示例3: smart_repr

# 需要导入模块: from rest_framework import fields [as 别名]
# 或者: from rest_framework.fields import Field [as 别名]
def smart_repr(value):
    if isinstance(value, QuerySet):
        return manager_repr(value)

    if isinstance(value, BaseField):
        return mongo_field_repr(value)

    if isinstance(value, BaseDocument):
        return mongo_field_repr(value)

    if isinstance(value, Field):
        return field_repr(value)

    value = repr(value)

    # Representations like u'help text'
    # should simply be presented as 'help text'
    value = uni_lit_re.sub("'\\1'", value)

    # Representations like
    # <django.core.validators.RegexValidator object at 0x1047af050>
    # Should be presented as
    # <django.core.validators.RegexValidator object>
    value = re.sub(' at 0x[0-9a-f]{4,32}>', '>', value)

    return value 
开发者ID:umutbozkurt,项目名称:django-rest-framework-mongoengine,代码行数:28,代码来源:repr.py

示例4: _get_validator

# 需要导入模块: from rest_framework import fields [as 别名]
# 或者: from rest_framework.fields import Field [as 别名]
def _get_validator(self) -> Field:
        return ValidatorFactory.make(self.param.annotation, self.settings) 
开发者ID:rsinger86,项目名称:drf-typed-views,代码行数:4,代码来源:params.py


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