當前位置: 首頁>>代碼示例>>Python>>正文


Python forms.RegistrationFormUniqueEmail方法代碼示例

本文整理匯總了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()) 
開發者ID:znick,項目名稱:anytask,代碼行數:25,代碼來源:forms.py

示例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()) 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:20,代碼來源:tests.py

示例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')}) 
開發者ID:kboard,項目名稱:kboard,代碼行數:14,代碼來源:forms.py


注:本文中的registration.forms.RegistrationFormUniqueEmail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。