forms.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:django-username-email 作者: tmm 项目源码 文件源码
def clean(self):
        email = self.cleaned_data.get('email')
        password = self.cleaned_data.get('password')

        if email and password:
            if django.VERSION >= (1, 11):
                self.user_cache = authenticate(self.request, email=email, password=password)
            else:
                self.user_cache = authenticate(email=email, password=password)
            if self.user_cache is None:
                raise forms.ValidationError(
                    self.error_messages['invalid_login'],
                    code='invalid_login',
                    params={'username': self.username_field.verbose_name},
                )
            else:
                self.confirm_login_allowed(self.user_cache)

        return self.cleaned_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号