Я пытаюсь запустить свой проект Django, но всякий раз, когда я регистрирую новую учетную запись, я получаю следующую ошибку: 'str' object has no attribute 'decode'
Я не понимаю, откуда это ; для аутентификации и регистрации я использую django-allauth
, и до сих пор у меня никогда не было этой проблемы. В чем может быть проблема? Вот полная трассировка (я использую Django 3):
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/account/login/?next=/
Django Version: 3.0.6
Python Version: 3.8.3
Installed Applications:
['channels',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main.apps.MainConfig',
'faqs.apps.FaqsConfig',
'django.contrib.sites',
'django_otp',
'django_otp.plugins.otp_static',
'django_otp.plugins.otp_totp',
'two_factor',
'allauth',
'allauth.account',
'allauth.socialaccount',
'rest_framework_mongoengine',
'rest_framework',
'corsheaders',
'django_filters']
Installed Middleware:
['corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'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',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_otp.middleware.OTPMiddleware']
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\backends.py", line 46, in authenticate
user = UserModel._default_manager.get_by_natural_key(username)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\base_user.py", line 44, in get_by_natural_key
return self.get(**{self.model.USERNAME_FIELD: username})
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 415, in get
raise self.model.DoesNotExist(
During handling of the above exception (User matching query does not exist.), another exception occurred:
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\decorators\debug.py", line 76, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\formtools\wizard\views.py", line 244, in dispatch
response = super().dispatch(request, *args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\generic\base.py", line 97, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\two_factor\views\core.py", line 99, in post
return super().post(*args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\two_factor\views\utils.py", line 128, in post
return super().post(*args, **kwargs)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\formtools\wizard\views.py", line 294, in post
if form.is_valid():
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\forms\forms.py", line 180, in is_valid
return self.is_bound and not self.errors
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\forms\forms.py", line 175, in errors
self.full_clean()
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\forms\forms.py", line 377, in full_clean
self._clean_form()
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\forms\forms.py", line 404, in _clean_form
cleaned_data = self.clean()
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\forms.py", line 214, in clean
self.user_cache = authenticate(self.request, username=username, password=password)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\__init__.py", line 72, in authenticate
user = backend.authenticate(request, **credentials)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\backends.py", line 50, in authenticate
UserModel().set_password(password)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\base_user.py", line 98, in set_password
self.password = make_password(raw_password)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\hashers.py", line 77, in make_password
return hasher.encode(password, salt)
File "C:\Users\david\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\auth\hashers.py", line 416, in encode
return "%s$%s" % (self.algorithm, data.decode('ascii'))
Exception Type: AttributeError at /account/login/
Exception Value: 'str' object has no attribute 'decode'