#python #django #email #python-unicode #reset-password
Вопрос:
Я пытаюсь сбросить систему паролей в django python. поэтому я делаю это
url.py
from django.urls import path
from app import views
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.auth import views as auth_views
from .forms import LoginForm, MyPasswordChangeForm, MyPasswordResetForm
urlpatterns = [ path('passwordchange/', auth_views.PasswordChangeView.as_view(template_name='app/passwordchange.html', success_url="/passwordchangedone/", form_class=MyPasswordChangeForm), name='passwordchange'),
path('passwordchangedone/', auth_views.PasswordChangeView.as_view(template_name='app/passwordchangedone.html'), name='passwordchangedone'),
path('password-reset/', auth_views.PasswordResetView.as_view(template_name='app/password_reset.html',form_class=MyPasswordResetForm), name='password_reset'),
path('password-reset/done/', auth_views.PasswordResetDoneView.as_view(template_name='app/password_reset_done.html'), name='password_reset_done'),
path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name='app/password_reset_confirm.html'), name='password_reset_confirm'),
path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(template_name='app/password_reset_complete.html'), name='password_reset_complete'), ]
и это мое settings.py
class MyPasswordResetForm(PasswordResetForm):
email = forms.EmailField(label=_("Email"), max_length=254,widget=forms.EmailInput(attrs={'autocomplete':'email','class':'form-control'}))
и это моя полная обратная связь
Environment:
Request Method: POST
Request URL: https://webtest.or.id/password-reset/
Django Version: 3.2.8
Python Version: 3.8.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
'maintenance_mode']
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',
'maintenance_mode.middleware.MaintenanceModeMiddleware']
.
Traceback (most recent call last):
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/contrib/auth/views.py", line 222, in dispatch
return super().dispatch(*args, **kwargs)
File "/home/minhaju1/virtualenv/web_tes/3.8/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/views/generic/edit.py", line 142, in post
return self.form_valid(form)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/contrib/auth/views.py", line 235, in form_valid
form.save(**opts)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/contrib/auth/forms.py", line 310, in save
self.send_mail(
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/contrib/auth/forms.py", line 260, in send_mail
email_message.send()
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/core/mail/message.py", line 284, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/core/mail/backends/console.py", line 34, in send_messages
self.write_message(message)
File "/home/minhaju1/virtualenv/web_test/3.8/lib/python3.8/site-packages/django/core/mail/backends/console.py", line 21, in write_message
self.stream.write('%sn' % msg_data)
Exception Type: UnicodeEncodeError at /password-reset/
Exception Value: 'ascii' codec can't encode character 'u2019' in position 609: ordinal not in range(128)
я пытаюсь импортировать все, что нужно этой системе, но все еще не работает, я пытаюсь скопировать и вставить код из моего другого проекта, но все еще не работает, я пытаюсь сопоставить свой сценарий и сценарий другого проекта, который я добавил, который отсутствует в моем сценарии, но не работает.
любой может помочь
Комментарии:
1. Можете ли вы добавить полную обратную связь?
2. конечно, я уже читал, добавляю это
3. всегда помещайте полное сообщение об ошибке (начинающееся со слова «Обратная связь») в вопрос (не комментарий) в виде текста (не скриншот, не ссылка на внешний портал). Есть и другая полезная информация.