本文整理汇总了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)
示例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.'),
})
示例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',
)
示例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
示例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)
示例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
示例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)
示例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)
示例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,
)
示例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,
})
示例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)
示例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"])
示例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)
示例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)
示例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)