在处理上述异常(authenticate()得到了意外的关键字参数'email')期间,发生了另一个异常:

时间:2018-06-19 17:02:12

标签: python django python-3.x login django-allauth

现在我正在研究Django项目。我们正在使用django-allauth进行用户注册。

当我们尝试使用错误的密码登录时,如果Debug = True一切正常;但是如果Debug = False,则会发生以下异常:

During handling of the above exception (authenticate() got an unexpected keyword argument 'email'),
another exception occurred:

Traceback (most recent call last):
  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper

    return view(request, *args, **kwargs)
  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/allauth/account/views.py", line 133, in dispatch
    return super(LoginView, self).dispatch(request, *args, **kwargs)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/allauth/account/views.py", line 79, in dispatch
    **kwargs)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/allauth/account/views.py", line 101, in post
    if form.is_valid():

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/forms/forms.py", line 183, in is_valid
    return self.is_bound and not self.errors

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/forms/forms.py", line 175, in errors
    self.full_clean()

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/forms/forms.py", line 385, in full_clean
    self._clean_form()

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/forms/forms.py", line 412, in _clean_form
    cleaned_data = self.clean()

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/allauth/account/forms.py", line 159, in clean
    **credentials)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/allauth/account/adapter.py", line 483, in authenticate
    user = authenticate(request=request, **credentials)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/allauth/compat.py", line 52, in authenticate
    return authenticate(request=request, **credentials)

  File "/Volumes/data/Peak/pyenv/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 77, in authenticate
    inspect.getcallargs(backend.authenticate, request=request, **credentials)

KeyError: 'request'
2018-06-19 17:44:54,697 "POST /accounts/login/ HTTP/1.1" 500 160691
ERROR:django.server:"POST /accounts/login/ HTTP/1.1" 500 160691

我该如何解决?

我们正在使用python3。

1 个答案:

答案 0 :(得分:0)

需要升级Django版本。 这不是代码错误。只是Django版本错误。 安装Django 1.11.4. 可以。