当单击更改密码为空白页但密码已更改时django

时间:2018-12-14 11:05:09

标签: python django python-3.x django-2.1

我创建登录页面。我的问题是“忘记密码”。用户输入邮件,django发送带有链接的消息。单击时必须更改密码。当完成时单击“更改密码”,我们应该在下一页上移动,但是它为空白。但是密码已更改。

account / urls.py

from django.urls import path, reverse_lazy
from django.contrib.auth import views as auth_views
from . import views

app_name = 'account'

urlpatterns = [
    path('', auth_views.LoginView.as_view(template_name='account/login.html'), name='login'),
    path('logout/', auth_views.LogoutView.
         as_view(template_name='registration/logout.html'), name='logout'),
    path('logout_then_login/', auth_views.logout_then_login, name='logout_then_login'),
    path('dashboard/', views.dashboard, name='dashboard'),
    path('password_change/', auth_views.PasswordChangeView.
         as_view(success_url=reverse_lazy('account:password_change_done')), name='password_change'),
    path('password_change_done/', auth_views.PasswordChangeDoneView.
         as_view(template_name='registration/password_change_done.html'),
         name='password_change_done'),
    path('password_reset/', auth_views.PasswordResetView.
         as_view(template_name='registration/password_reset_form.html',
                 html_email_template_name='registration/password_reset_mail.html'),
         name='password_reset'),
    path('password_reset/done', auth_views.PasswordResetDoneView.
         as_view(template_name='registration/password_reset_done.html'),
         name='password_reset_done'),
    path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.
         as_view(template_name='registration/password_reset_confirm.html'),
         name='password_reset_confirm'),
    path('reset/done', auth_views.PasswordResetCompleteView.
         as_view(template_name='registration/password_reset_complete.html'),
         name='password_reset_complete')
]

password_reset_complete.html

{% extends "base.html" %}

{% block title %}
    <p>Password was changed</p>
{% endblock %}

settings.py

LOGIN_REDIRECT_URL = reverse_lazy('account:dashboard')
LOGIN_URL = reverse_lazy('account:login')
SUCCESS_URL = reverse_lazy('account:password_change_done')

这是正确的吗?

urls.py

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('account.urls')),
    path('', include('django.contrib.auth.urls')),
]

1 个答案:

答案 0 :(得分:0)

我假设base.html包含一个内容块。所以您只是想念

{% block content %}{% endblock %}

password_reset_complete.html的一部分。