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


Python serializers.EmailField方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import EmailField [as 別名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.email_field = get_user_email_field_name(User)
        self.fields[self.email_field] = serializers.EmailField() 
開發者ID:sunscrapers,項目名稱:djoser,代碼行數:7,代碼來源:serializers.py

示例2: test_should_email_convert_string

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

示例3: __init__

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import EmailField [as 別名]
def __init__(self, allow_extra):
        class Model(serializers.Serializer):
            id = serializers.IntegerField()
            client_name = serializers.CharField(max_length=255, trim_whitespace=False)
            sort_index = serializers.FloatField()
            # client_email = serializers.EmailField(required=False, allow_null=True)
            client_phone = serializers.CharField(max_length=255, trim_whitespace=False, required=False, allow_null=True)

            class Location(serializers.Serializer):
                latitude = serializers.FloatField(required=False, allow_null=True)
                longitude = serializers.FloatField(required=False, allow_null=True)
            location = Location(required=False, allow_null=True)

            contractor = serializers.IntegerField(required=False, allow_null=True, min_value=0)
            upstream_http_referrer = serializers.CharField(
                max_length=1023, trim_whitespace=False, required=False, allow_null=True
            )
            grecaptcha_response = serializers.CharField(min_length=20, max_length=1000, trim_whitespace=False)
            last_updated = serializers.DateTimeField(required=False, allow_null=True)

            class Skill(serializers.Serializer):
                subject = serializers.CharField()
                subject_id = serializers.IntegerField()
                category = serializers.CharField()
                qual_level = serializers.CharField()
                qual_level_id = serializers.IntegerField()
                qual_level_ranking = serializers.FloatField(default=0)
            skills = serializers.ListField(child=Skill())

        self.allow_extra = allow_extra  # unused
        self.serializer = Model 
開發者ID:samuelcolvin,項目名稱:pydantic,代碼行數:33,代碼來源:test_drf.py

示例4: make_string_validator

# 需要導入模塊: from rest_framework import serializers [as 別名]
# 或者: from rest_framework.serializers import EmailField [as 別名]
def make_string_validator(cls, settings: ParamSettings):
        if settings.regex:
            return serializers.RegexField(
                settings.regex,
                default=settings.default,
                max_length=settings.max_length,
                min_length=settings.min_length,
            )

        if settings.format is None:
            return serializers.CharField(
                default=settings.default,
                max_length=settings.max_length,
                min_length=settings.min_length,
                trim_whitespace=settings.trim_whitespace,
            )

        if settings.format == "email":
            return serializers.EmailField(
                default=settings.default,
                max_length=settings.max_length,
                min_length=settings.min_length,
            )

        if settings.format == "slug":
            return serializers.SlugField(
                default=settings.default,
                max_length=settings.max_length,
                min_length=settings.min_length,
            )

        if settings.format == "url":
            return serializers.URLField(
                default=settings.default,
                max_length=settings.max_length,
                min_length=settings.min_length,
            )

        if settings.format == "uuid":
            return serializers.UUIDField(default=settings.default)

        if settings.format == "file_path":
            return serializers.FilePathField(
                default=settings.default,
                path=settings.path,
                match=settings.match,
                recursive=settings.recursive,
                allow_files=settings.allow_files,
                allow_folders=settings.allow_folders,
            )

        if settings.format == "ipv6":
            return serializers.IPAddressField(default=settings.default, protocol="IPv6")

        if settings.format == "ipv4":
            return serializers.IPAddressField(default=settings.default, protocol="IPv4")

        if settings.format == "ip":
            return serializers.IPAddressField(default=settings.default, protocol="both") 
開發者ID:rsinger86,項目名稱:drf-typed-views,代碼行數:61,代碼來源:validator_factory.py


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