本文整理匯總了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)