本文整理匯總了Python中registration.forms.RegistrationFormUniqueEmail方法的典型用法代碼示例。如果您正苦於以下問題:Python forms.RegistrationFormUniqueEmail方法的具體用法?Python forms.RegistrationFormUniqueEmail怎麽用?Python forms.RegistrationFormUniqueEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類registration.forms
的用法示例。
在下文中一共展示了forms.RegistrationFormUniqueEmail方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_registration_form_unique_email
# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationFormUniqueEmail [as 別名]
def test_registration_form_unique_email(self):
"""
Test that ``RegistrationFormUniqueEmail`` validates uniqueness
of email addresses.
"""
# Create a user so we can verify that duplicate addresses
# aren't permitted.
User.objects.create_user('alice', 'alice@example.com', 'secret')
form = forms.RegistrationFormUniqueEmail(data={'username': 'foo',
'email': 'alice@example.com',
'password1': 'foo',
'password2': 'foo'})
self.failIf(form.is_valid())
self.assertEqual(form.errors['email'],
[u"This email address is already in use. Please supply a different email address."])
form = forms.RegistrationFormUniqueEmail(data={'username': 'foo',
'email': 'foo@example.com',
'password1': 'foo',
'password2': 'foo'})
self.failUnless(form.is_valid())
示例2: test_registration_form_unique_email
# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationFormUniqueEmail [as 別名]
def test_registration_form_unique_email(self):
"""
Test that ``RegistrationFormUniqueEmail`` validates uniqueness
of email addresses.
"""
form = forms.RegistrationFormUniqueEmail(data={ 'username': 'foo',
'email': 'alice@example.com',
'password1': 'foo',
'password2': 'foo' })
self.failIf(form.is_valid())
self.assertEqual(form.errors['email'], [u"This email address is already in use. Please supply a different email address."])
form = forms.RegistrationFormUniqueEmail(data={ 'username': 'foo',
'email': 'foo@example.com',
'password1': 'foo',
'password2': 'foo' })
self.failUnless(form.is_valid())
示例3: __init__
# 需要導入模塊: from registration import forms [as 別名]
# 或者: from registration.forms import RegistrationFormUniqueEmail [as 別名]
def __init__(self, *args, **kwargs):
super(RegistrationFormUniqueEmail, self).__init__(*args, **kwargs)
if 'username' in self.fields:
self.fields['username'].widget.attrs.update({'placeholder': _(u'Your ID'), 'autofocus': ''})
if 'name' in self.fields:
self.fields['name'].widget.attrs.update({'placeholder': _(u'Your name')})
if 'email' in self.fields:
self.fields['email'].widget.attrs.update({'placeholder': _(u'Your email')})
if 'password1' in self.fields:
self.fields['password1'].widget.attrs.update({'placeholder': _(u'Enter password')})
if 'password2' in self.fields:
self.fields['password2'].widget.attrs.update({'placeholder': _(u'Confirm password')})