本文整理汇总了Python中django.forms.EmailInput方法的典型用法代码示例。如果您正苦于以下问题:Python forms.EmailInput方法的具体用法?Python forms.EmailInput怎么用?Python forms.EmailInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms
的用法示例。
在下文中一共展示了forms.EmailInput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailInput [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.'),
})
示例2: __init__
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailInput [as 别名]
def __init__(self, *args, **kwargs):
kwargs.setdefault('label_suffix', '')
super(PoliticianForm, self).__init__(*args, **kwargs)
for field_name, field in self.fields.items():
if isinstance(field.widget, forms.TextInput) or isinstance(field.widget, forms.Select) or isinstance(field.widget, forms.EmailInput):
field.widget.attrs.update({
'class': 'form-control'
})
if field_name == 'party':
field.choices = [('', '---------')]
field.choices += [
(p.id, p.name)
for p
in Party.objects.order_by('name')
]
if isinstance(field.widget, forms.Textarea):
field.widget.attrs.update({
'class': 'form-control',
'rows': 2,
})
示例3: prepare_email
# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import EmailInput [as 别名]
def prepare_email(self, field):
field_attrs = field.build_field_attrs()
widget_attrs = field.build_widget_attrs(extra_attrs={'autocomplete': 'email'})
field_attrs.update({
'widget': forms.EmailInput(attrs=widget_attrs),
})
return forms.EmailField(**field_attrs)