在处理上述异常(authenticate()获得意外的关键字参数“email”)的过程中,发生了另一个异常:

2024-04-20 03:59:10 发布

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

现在我在做一个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。在


Tags: djangoinpyselfpyenvdataresponserequest