Django 비밀번호 재설정 및 비밀번호 변경

5942 단어
메인 프로젝트의 urls.py

from django.contrib import admin
from django.urls import path,include
from django.contrib.auth import views as user_views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include('users.urls')),
    path('',include('app.urls')),

    path('password-change/',user_views.PasswordChangeView.as_view(template_name='users/password_change.html'),name='password-change'),
    path('password-change-done/', user_views.PasswordChangeDoneView.as_view(template_name='users/password_change_done.html'),name='password_change_done'),
    path('password-reset/', user_views.PasswordResetView.as_view(template_name='users/password_reset.html'),name='password_reset'),
    path('password-reset-done/',user_views.PasswordResetDoneView.as_view(template_name='users/password_reset_done.html'),name='password_reset_done'),
    path('password-reset-confirm/<uidb64>/<token>/',user_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'),name='password_reset_confirm'),
    path('password-reset-complete/',user_views.PasswordResetCompleteView.as_view(template_name='users/password_reset_complete.html'),name='password_reset_complete')
]



템플릿 폴더에서 생성해야 하는 HTML:

password_change.html
password_change_done.html
password_reset.html
password_reset_done.html
password_reset_confirm.html
password_reset_complete.html

settings.py

클라이언트 재설정 비밀번호로 이메일을 보내기 위한 이 설정

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'Email'
EMAIL_HOST_PASSWORD = 'Password'

좋은 웹페이지 즐겨찾기