DjangoalAuth DefaultAccountAdapter clean_password()获得意外的关键字参数“user”

2024-10-04 05:31:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经用django allauth和django1.10编写了自己的自定义帐户适配器,这样我就可以为要验证的密码指定一个regex模式。在

这是我的代码片段:

class MyAccountAdapter(DefaultAccountAdapter):
    def clean_password(self, password):
        if re.match(settings.ACCOUNT_PASSWORD_REGEX, password):
            return password
        else:
            raise ValidationError("Password must be at least 8 characters long, contain one digit and one captalised alphabet")  

我已经在我的设置.py

ACCOUNT_ADAPTER = 'app.adapters.MyAccountAdapter'

当我试图注册(即提交一份填妥的表格)时,我收到以下错误:

TypeError at /accounts/signup/

clean_password() got an unexpected keyword argument 'user'

回溯:

^{pr2}$

这个神秘的错误是什么意思,我该如何修复它?在


Tags: django代码clean密码错误模式帐户account
1条回答
网友
1楼 · 发布于 2024-10-04 05:31:56

看看DefaultAccountAdapterclean_password实现:

def clean_password(self, password, user=None):
        """
        Validates a password. You can hook into this if you want to
        restric the allowed password choices.
        """

缺少user关键字参数。在

相关问题 更多 >