当前位置: 首页>>代码示例>>Python>>正文


Python AuthenticationForm.non_field_errors方法代码示例

本文整理汇总了Python中django.contrib.auth.forms.AuthenticationForm.non_field_errors方法的典型用法代码示例。如果您正苦于以下问题:Python AuthenticationForm.non_field_errors方法的具体用法?Python AuthenticationForm.non_field_errors怎么用?Python AuthenticationForm.non_field_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.auth.forms.AuthenticationForm的用法示例。


在下文中一共展示了AuthenticationForm.non_field_errors方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_invalid_username

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
    def test_invalid_username(self):
        # The user submits an invalid username.

        data = {"username": "jsmith_does_not_exist", "password": "test123"}
        form = AuthenticationForm(None, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form.non_field_errors(), [force_unicode(form.error_messages["invalid_login"])])
开发者ID:colonialclub,项目名称:colonial-appengine,代码行数:9,代码来源:forms.py

示例2: test_inactive_user_i18n

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_inactive_user_i18n(self):
     with self.settings(USE_I18N=True), translation.override("pt-br", deactivate=True):
         # The user is inactive.
         data = {"username": "inactive", "password": "password"}
         form = AuthenticationForm(None, data)
         self.assertFalse(form.is_valid())
         self.assertEqual(form.non_field_errors(), [force_text(form.error_messages["inactive"])])
开发者ID:addsimm,项目名称:cms8,代码行数:9,代码来源:test_forms.py

示例3: test_success

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_success(self):
     # The success case
     data = {
         'username': 'testclient',
         'password': 'password',
     }
     form = AuthenticationForm(None, data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.non_field_errors(), [])
开发者ID:DAWZayas-Projects,项目名称:TEJEDOR-RETUERTO-ALEJANDRO,代码行数:11,代码来源:test_forms.py

示例4: test_unicode_username

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_unicode_username(self):
     User.objects.create_user(username='Σαρα', password='pwd')
     data = {
         'username': 'Σαρα',
         'password': 'pwd',
     }
     form = AuthenticationForm(None, data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.non_field_errors(), [])
开发者ID:CodeMonk,项目名称:django,代码行数:11,代码来源:test_forms.py

示例5: test_inactive_user

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_inactive_user(self):
     # The user is inactive.
     data = {
         'username': 'inactive',
         'password': 'password',
     }
     form = AuthenticationForm(None, data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.non_field_errors(), [str(form.error_messages['inactive'])])
开发者ID:CodeMonk,项目名称:django,代码行数:11,代码来源:test_forms.py

示例6: test_inactive_user_i18n

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_inactive_user_i18n(self):
     with self.settings(USE_I18N=True), translation.override('pt-br', deactivate=True):
         # The user is inactive.
         data = {
             'username': 'inactive',
             'password': 'password',
         }
         form = AuthenticationForm(None, data)
         self.assertFalse(form.is_valid())
         self.assertEqual(form.non_field_errors(), [str(form.error_messages['inactive'])])
开发者ID:CodeMonk,项目名称:django,代码行数:12,代码来源:test_forms.py

示例7: test_invalid_username

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
    def test_invalid_username(self):
        # The user submits an invalid username.

        data = {
            'username': 'jsmith_does_not_exist',
            'password': 'test123',
            }
        form = AuthenticationForm(None, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form.non_field_errors(),
                         [u'Please enter a correct username and password. Note that both fields are case-sensitive.'])
开发者ID:brunogamacatao,项目名称:portalsaladeaula,代码行数:13,代码来源:forms.py

示例8: test_invalid_username

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
    def test_invalid_username(self):
        # The user submits an invalid username.

        data = {
            'username': 'jsmith_does_not_exist',
            'password': 'test123',
            }
        form = AuthenticationForm(None, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form.non_field_errors(),
                         [force_text(form.error_messages['invalid_login'])])
开发者ID:LUMC,项目名称:django,代码行数:13,代码来源:forms.py

示例9: test_invalid_username

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
    def test_invalid_username(self):
        # The user submits an invalid username.

        data = {"username": "jsmith_does_not_exist", "password": "test123"}
        form = AuthenticationForm(None, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(
            form.non_field_errors(),
            [
                force_text(
                    form.error_messages["invalid_login"] % {"username": User._meta.get_field("username").verbose_name}
                )
            ],
        )
开发者ID:HiddenData,项目名称:django,代码行数:16,代码来源:forms.py

示例10: test_inactive_user_incorrect_password

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_inactive_user_incorrect_password(self):
     """An invalid login doesn't leak the inactive status of a user."""
     data = {
         'username': 'inactive',
         'password': 'incorrect',
     }
     form = AuthenticationForm(None, data)
     self.assertFalse(form.is_valid())
     self.assertEqual(
         form.non_field_errors(), [
             form.error_messages['invalid_login'] % {
                 'username': User._meta.get_field('username').verbose_name
             }
         ]
     )
开发者ID:CodeMonk,项目名称:django,代码行数:17,代码来源:test_forms.py

示例11: login

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
def login(request, template_name='registration/login.html'):
    form = AuthenticationForm(data=request.POST)

    if request.method == "POST":
        if not form.is_valid():
            non_field_errors = form.non_field_errors()

            if non_field_errors:
                # test if the account is not active
                user_inactive = non_field_errors[0].find(_("This account is inactive.")) != -1
                #                user_inactive = User.objects.filter(username=request.POST.get('username'), is_active=0).count() == 1

                if user_inactive:
                    return render(request, template_name, {'form': form, 'user_inactive': user_inactive, })

    return django_login(request)
开发者ID:dhootha,项目名称:akenergo,代码行数:18,代码来源:views.py

示例12: test_success

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_success(self):
     # The success case
     data = {"username": "testclient", "password": "password"}
     form = AuthenticationForm(None, data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.non_field_errors(), [])
开发者ID:colonialclub,项目名称:colonial-appengine,代码行数:8,代码来源:forms.py

示例13: test_inactive_user

# 需要导入模块: from django.contrib.auth.forms import AuthenticationForm [as 别名]
# 或者: from django.contrib.auth.forms.AuthenticationForm import non_field_errors [as 别名]
 def test_inactive_user(self):
     # The user is inactive.
     data = {"username": "inactive", "password": "password"}
     form = AuthenticationForm(None, data)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.non_field_errors(), [force_unicode(form.error_messages["inactive"])])
开发者ID:colonialclub,项目名称:colonial-appengine,代码行数:8,代码来源:forms.py


注:本文中的django.contrib.auth.forms.AuthenticationForm.non_field_errors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。