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


Python forms.EmailField方法代码示例

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


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

示例1: get_field_kind

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def get_field_kind(field):
  if field['kind'] == 'string':
    return forms.CharField(max_length=255, required=False)
  elif field['kind'] == 'email':
    return forms.EmailField(max_length=255, required=False)
  elif field['kind'] == 'integer':
    return forms.IntegerField(required=False)
  elif field['kind'] == 'boolean':
    return forms.BooleanField(required=False)
  elif field['kind'] == 'text':
    return forms.CharField(widget=forms.Textarea(), required=False)
  elif field['kind'] == 'choice':
    return forms.ChoiceField(choices=map(lambda c: (c,c), field['choices']))
  elif field['kind'] == 'timezones':
    return TimezoneField()
  elif field['kind'] == 'authentication':
    return SwitchField('user', 'service', required=True)
  elif field['kind'] == 'json':
    return JsonField(required=False)
  elif field['kind'] == 'integer_list':
    return CommaSeparatedIntegerField(required=False)
  elif field['kind'] == 'string_list':
    return CommaSeparatedCharField(required=False)
  else:
    return forms.CharField(max_length=255, required=False) 
开发者ID:google,项目名称:starthinker,代码行数:27,代码来源:forms_json.py

示例2: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        super(UpdateEmailForm, self).__init__(*args, **kwargs)

        self.fields['email'] = forms.EmailField(
            initial=self.user.email,
            widget=forms.EmailInput(attrs={
                'placeholder': _('Email')
            }),
            error_messages={
                'required': _('Please enter your new email address.'),
                'invalid': _('Please enter a valid email address.')
            })

        self.fields['password'] = forms.CharField(
            widget=forms.PasswordInput(attrs={
                'placeholder': _('Password')
            }),
            error_messages={
                'required': _('Please enter your password.'),
            }) 
开发者ID:nlhkabu,项目名称:connect,代码行数:23,代码来源:forms.py

示例3: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def __init__(self, event=None, *args, **kwargs):
        super(DonationEntryForm, self).__init__(*args, **kwargs)
        minDonationAmount = (
            event.minimumdonation if event is not None else Decimal('1.00')
        )
        self.fields['amount'] = forms.DecimalField(
            decimal_places=2,
            min_value=minDonationAmount,
            max_value=Decimal('100000'),
            label='Donation Amount (min ${0})'.format(minDonationAmount),
            widget=tracker.widgets.NumberInput(
                attrs={
                    'id': 'iDonationAmount',
                    'min': str(minDonationAmount),
                    'step': '0.01',
                }
            ),
            required=True,
        )
        self.fields['comment'] = forms.CharField(widget=forms.Textarea, required=False)
        self.fields['requestedvisibility'] = forms.ChoiceField(
            initial='CURR',
            choices=models.Donation._meta.get_field('requestedvisibility').choices,
            label='Name Visibility',
        )
        self.fields['requestedalias'] = forms.CharField(
            max_length=32, label='Preferred Alias', required=False
        )
        self.fields['requestedemail'] = forms.EmailField(
            max_length=128, label='Preferred Email', required=False
        )
        self.fields['requestedsolicitemail'] = forms.ChoiceField(
            initial='CURR',
            choices=models.Donation._meta.get_field('requestedsolicitemail').choices,
            label='Charity Email Opt In',
        ) 
开发者ID:GamesDoneQuick,项目名称:donation-tracker,代码行数:38,代码来源:forms.py

示例4: make_entry_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def make_entry_field(self, fieldsubmission=None):
        c = forms.EmailField(required=self.config['required'],
            label=self.config['label'],
            help_text=self.config['help_text'])

        if fieldsubmission:
            c.initial = fieldsubmission.data['info']

        return c 
开发者ID:sfu-fas,项目名称:coursys,代码行数:11,代码来源:text.py

示例5: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def __init__(self, *args, **kwargs):
        # max_length=254 to be compliant with RFCs 3696 and 5321
        kwargs['max_length'] = kwargs.get('max_length', 254)
        super(EmailField, self).__init__(*args, **kwargs) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:6,代码来源:__init__.py

示例6: deconstruct

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def deconstruct(self):
        name, path, args, kwargs = super(EmailField, self).deconstruct()
        # We do not exclude max_length if it matches default as we want to change
        # the default in future.
        return name, path, args, kwargs 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:__init__.py

示例7: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def formfield(self, **kwargs):
        # As with CharField, this will cause email validation to be performed
        # twice.
        defaults = {
            'form_class': forms.EmailField,
        }
        defaults.update(kwargs)
        return super(EmailField, self).formfield(**defaults) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:10,代码来源:__init__.py

示例8: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def formfield(self, **kwargs):
        # As with CharField, this will cause email validation to be performed
        # twice.
        defaults = {
            'form_class': forms.EmailField,
        }
        defaults.update(kwargs)
        return super().formfield(**defaults) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:10,代码来源:__init__.py

示例9: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def __init__(self, *args, **kwargs):
        super(UserCreationFormExtended, self).__init__(*args, **kwargs)
        self.fields['email'] = forms.EmailField(
            label=_("E-mail"),
            max_length=75,
        ) 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:8,代码来源:forms.py

示例10: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def formfield(self, **kwargs):
        # As with CharField, this will cause email validation to be performed
        # twice.
        return super().formfield(**{
            'form_class': forms.EmailField,
            **kwargs,
        }) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:9,代码来源:__init__.py

示例11: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def __init__(self, required=True, help_text=None, validators=(), **kwargs):
        self.field = forms.EmailField(
            required=required,
            help_text=help_text,
            validators=validators,
        )
        super().__init__(**kwargs) 
开发者ID:wagtail,项目名称:wagtail,代码行数:9,代码来源:field_block.py

示例12: test_email_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def test_email_field(self):
        data = self.get_form_field_data("email")
        cls = wsf_fields.EmailField()
        field = cls.get_formfield(data)

        self.assertIsInstance(field, forms.EmailField)
        self.assertIsInstance(field.widget, forms.widgets.EmailInput)
        self.assertEqual(field.label, data["label"])
        self.assertEqual(field.required, data["required"])
        self.assertEqual(field.help_text, data["help_text"])
        self.assertEqual(field.initial, data["default_value"]) 
开发者ID:labd,项目名称:wagtailstreamforms,代码行数:13,代码来源:test_fields.py

示例13: test_should_email_convert_string

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def test_should_email_convert_string():
    assert_conversion(forms.EmailField, String) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:test_converter.py

示例14: get_form_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def get_form_field(self, **kwargs):
    """Return a Django form field appropriate for a User property.

    This defaults to a forms.EmailField instance, except if auto_current_user or
    auto_current_user_add is set, in which case None is returned, as such
    'auto' fields should not be rendered as part of the form.
    """
    if self.auto_current_user or self.auto_current_user_add:
      return None
    defaults = {'form_class': forms.EmailField}
    defaults.update(kwargs)
    return super(UserProperty, self).get_form_field(**defaults) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:14,代码来源:djangoforms.py

示例15: add_fields

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailField [as 别名]
def add_fields(self, form, index):
        form.fields["email"] = EmailField(label=email_field_label) 
开发者ID:iguana-project,项目名称:iguana,代码行数:4,代码来源:forms.py


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