Я настроил Django Rest Auth с пользовательской моделью пользователя, расширив класс Abstract User. Я включил обязательное подтверждение по электронной почте. Когда я создаю суперпользователя из командной строки, я не могу войти в систему с этим пользователем, используя конечную точку входа Rest Auth. Я полагаю, что причина в том, что Rest Auth использует emailaddress_set для хранения писем пользователей, которые зарегистрировались, и отслеживает, были ли они проверены или нет. Но поскольку суперпользователь создается из командной строки, он не go в процессе добавления в emailaddress_set.
Возможно получить доступ к таблице с помощью консоли и добавить туда запись вручную, но это не самое элегантное решение. Кто-нибудь знает, как обойти это?
Это ошибка:
DoesNotExist at /authentication/login/
EmailAddress matching query does not exist.
Request Method: POST
Request URL: http://127.0.0.1:8000/authentication/login/
Django Version: 3.0.5
Python Executable: /home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/bin/python
Python Version: 3.7.5
Python Path: ['/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend', '/home/caronex/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/201.6668.115/plugins/python/helpers/pycharm', '/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages']
Server time: Thu, 30 Apr 2020 13:09:16 +0000
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'rest_framework',
'rest_framework.authtoken',
'django_filters',
'drf_yasg',
'corsheaders',
'rest_auth',
'rest_auth.registration',
'allauth',
'allauth.account',
'allauth.socialaccount',
'users_module',
'projects_module']
Installed Middleware:
('whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback (most recent call last):
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_auth/views.py", line 49, in dispatch
return super(LoginView, self).dispatch(*args, **kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
raise exc
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_auth/views.py", line 103, in post
self.serializer.is_valid(raise_exception=True)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_framework/serializers.py", line 234, in is_valid
self._validated_data = self.run_validation(self.initial_data)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_framework/serializers.py", line 436, in run_validation
value = self.validate(value)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/rest_auth/serializers.py", line 108, in validate
email_address = user.emailaddress_set.get(email=user.email)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/caronex/Tech/Projects/WebDev/Backend/ieee_project_manager_backend/venv/lib/python3.7/site-packages/django/db/models/query.py", line 417, in get
self.model._meta.object_name
Exception Type: DoesNotExist at /authentication/login/
Exception Value: EmailAddress matching query does not exist.
Request information:
USER: AnonymousUser
Вот мои настройки:
My Custom UserManager
Моя модель CustomUser
Здесь происходит ошибка в библиотеке rest_auth