我使用 django 的用户模型进行身份验证,现在我为我的项目添加了密码重置,用户没有收到任何电子邮件,但在终端我收到了这条消息,我在本地计算机上做所有这些
在我的终端
You're receiving this email because you requested a password reset for your user account at 127.0.0.1:8000.
Please go to the following page and choose a new password:
http://127.0.0.1:8000/accounts/reset/Mg/aisdmr-bd229ea69f64a159ed5c744816b02ca3/
Your username, in case you’ve forgotten: xxxxx
Thanks for using our site!
The 127.0.0.1:8000 team
在我的 urls.py
from django.urls import path
from django.contrib.auth import views as auth_views
from . import views
app_name = 'accounts'
urlpatterns = [
path('login/',
auth_views.LoginView.as_view(template_name='accounts/login.html'),
name='login'),
path('logout/',
auth_views.LogoutView.as_view(),
name='logout'),
path('signup/',
views.SignUp.as_view(),
name='signup'),
path('user/<int:pk>/',
views.UserList.as_view(template_name='accounts/about_user.html'),
name='about_user'),
path('reset_password/',auth_views.PasswordResetView.as_view(), name='reset_password'),
path('reset_password_sent/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),
]
在 settings.py
# SMTP configuration
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USER_TLS = True
EMAIL_HOST_USER = 'example@gmail.com'
EMAIL_HOST_PASSWORD = 'password'