Несколько объектов возвращено исключение при вводе неверного пароля в Django
Я использую cookie-нож Django и URL-адрес http://localhost:8000/accounts/login/ всякий раз, когда я ввожу неверный пароль. Я получаю следующую трассировку и 500 внутренних ошибок сервера на сетевой консоли. Я использую базу данных sqlite. Я не могу понять, почему я получаю эту ошибку, потому что при создании пустого проекта с использованием той же базы данных такая ошибка не выдается.
Environment:
Request Method: POST
Request URL: http://localhost:8000/accounts/login/
Django Version: 2.1.4
Python Version: 3.6.7
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'crispy_forms',
'allauth',
'allauth.account',
'allauth.socialaccount',
'rest_framework',
'widget_tweaks',
'core.users.apps.UsersAppConfig',
'core.userManagement.apps.UsermanagementConfig',
'debug_toolbar',
'django_extensions']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware']
Traceback:
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
45. return bound_method(*args, **kwargs)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/allauth/account/views.py" in dispatch
137. return super(LoginView, self).dispatch(request, *args, **kwargs)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/allauth/account/views.py" in dispatch
80. **kwargs)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/allauth/account/views.py" in post
102. if form.is_valid():
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/forms/forms.py" in is_valid
185. return self.is_bound and not self.errors
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/forms/forms.py" in errors
180. self.full_clean()
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/forms/forms.py" in full_clean
382. self._clean_form()
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/forms/forms.py" in _clean_form
409. cleaned_data = self.clean()
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/allauth/account/forms.py" in clean
179. **credentials)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/allauth/account/adapter.py" in authenticate
489. user = authenticate(request, **credentials)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in authenticate
73. user = backend.authenticate(request, **credentials)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/allauth/account/auth_backends.py" in authenticate
26. ret = self._authenticate_by_username(**credentials)
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/allauth/account/auth_backends.py" in _authenticate_by_username
40. user = filter_users_by_username(username).get()
File "/home/power/Documents/Projects/core/venv/lib/python3.6/site-packages/django/db/models/query.py" in get
403. (self.model._meta.object_name, num)
Exception Type: MultipleObjectsReturned at /accounts/login/
Exception Value: get() returned more than one User -- it returned 2!