[英]django-allauth DefaultAccountAdapter clean_password() got an unexpected keyword argument 'user'
I have written my own custom account adapter using django-allauth and django 1.10, so that I can specify a regex patterns for passwords to be validated. 我已经使用django-allauth和django 1.10编写了自己的自定义帐户适配器,以便可以为要验证的密码指定正则表达式模式。
This is a snippet of my code: 这是我的代码的片段:
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")
I have specified to use this class in my settings.py : 我已经在我的settings.py中指定使用此类:
ACCOUNT_ADAPTER = 'app.adapters.MyAccountAdapter'
When I attempt to sign up (ie submit a filled in form), I get the following error: 当我尝试注册(即提交填写的表单)时,出现以下错误:
TypeError at /accounts/signup/
位于/ accounts / signup /的TypeError
clean_password() got an unexpected keyword argument 'user'
clean_password()得到了意外的关键字参数'user'
Traceback: 追溯:
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'
What's the meaning of this cryptic error, and how do I fix it? 这个隐秘错误的含义是什么,我该如何解决?
Take a look at DefaultAccountAdapter
implementation of clean_password
: 看一下
clean_password
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.
"""
You are missing the user
keyword parameter. 您缺少
user
关键字参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.