Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django allauth DefaultAccountAdapter clean_password()获取了一个意外的关键字参数';用户';_Python_Django_Django Allauth - Fatal编程技术网

Python django allauth DefaultAccountAdapter clean_password()获取了一个意外的关键字参数';用户';

Python django allauth DefaultAccountAdapter clean_password()获取了一个意外的关键字参数';用户';,python,django,django-allauth,Python,Django,Django Allauth,我已经使用django allauth和django 1.10编写了自己的自定义帐户适配器,因此我可以为要验证的密码指定正则表达式模式 这是我的代码片段: class MyAccountAdapter(DefaultAccountAdapter): def clean_password(self, password): if re.match(settings.ACCOUNT_PASSWORD_REGEX, password): return pa

我已经使用django allauth和django 1.10编写了自己的自定义帐户适配器,因此我可以为要验证的密码指定正则表达式模式

这是我的代码片段:

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\u ADAPTER='app.adapters.MyAccountAdapter'

当我尝试注册(即提交填写的表格)时,我收到以下错误:

在/帐户/注册处键入错误/

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

回溯:

File "/path/to/site-packages/django/core/handlers/exception.py" in inner
  42.             response = get_response(request)

File "/path/to/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/path/to/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/path/to/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/path/to/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/path/to/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)

File "/path/to/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/path/to/site-packages/allauth/account/views.py" in dispatch
  205.         return super(SignupView, self).dispatch(request, *args, **kwargs)

File "/path/to/site-packages/allauth/account/views.py" in dispatch
  74.                                             **kwargs)

File "/path/to/site-packages/allauth/account/views.py" in dispatch
  183.                                                           **kwargs)

File "/path/to/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/path/to/site-packages/allauth/account/views.py" in post
  96.         if form.is_valid():

File "/path/to/site-packages/django/forms/forms.py" in is_valid
  169.         return self.is_bound and not self.errors

File "/path/to/site-packages/django/forms/forms.py" in errors
  161.             self.full_clean()

File "/path/to/site-packages/django/forms/forms.py" in full_clean
  371.         self._clean_form()

File "/path/to/site-packages/django/forms/forms.py" in _clean_form
  398.             cleaned_data = self.clean()

File "/path/to/site-packages/allauth/account/forms.py" in clean
  363.                     user=dummy_user)

Exception Type: TypeError at /accounts/signup/
Exception Value: clean_password() got an unexpected keyword argument 'user'

这个神秘错误的含义是什么?如何修复它?

请看
DefaultAccountAdapter
清除密码的实现:

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
关键字参数。

Gah!,当我搜索源代码时,我意识到函数签名是不一样的。这种情况一直发生在我身上,不过还是要感谢投票:D