尝试更改应用程序密码后,我收到此错误消息。
你知道这条路线失败的原因吗?
实际上,它正在更改密码,但并没有呈现成功模板“password\u change\u done.html”。
谢谢
应用程序/URL。py公司
from django.contrib.auth import views as auth_views
from django.urls import path
â
from . import views
â
app_name = 'account'
â
urlpatterns = [
# path('login/', views.user_login, name='login'),
path('', views.dashboard, name='dashboard'),
â
# login / logout urls
path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
path('logout/', auth_views.LogoutView.as_view(), name='logout'),
path('logout-then-login/', auth_views.logout_then_login, name='logout_then_login'),
â
# change password urls
path('password-change/', auth_views.PasswordChangeView.as_view(), name='password_change'),
path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(), name='password_change_done'),
]
â
â
错误消息
# NoReverseMatch at /account/password-change/
# Reverse for 'password_change_done' not found. 'password_change_done' is not a valid view function or pattern name.
# Request Method: POST
# Request URL: http://localhost:8000/account/password-change/
# Django Version: 2.0.4
# Exception Type: NoReverseMatch
# Exception Value:
# Reverse for 'password_change_done' not found. 'password_change_done' is not a valid view function or pattern name.
# Exception Location: C:\env\django_social_website\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 632
# Python Executable: C:\env\django_social_website\Scripts\python.exe
# Python Version: 3.6.3
# Python Path:
# ['C:\\Projects\\django_social_website',
# 'C:\\env\\django_social_website\\Scripts\\python36.zip',
# 'C:\\ProgramData\\Anaconda3\\DLLs',
# 'C:\\ProgramData\\Anaconda3\\lib',
# 'C:\\ProgramData\\Anaconda3',
# 'C:\\env\\django_social_website',
# 'C:\\env\\django_social_website\\lib\\site-packages',
# 'C:\\env\\django_social_website\\lib\\site-packages\\setuptools-28.8.0-py3.6.egg',
# 'C:\\env\\django_social_website\\lib\\site-packages\\pip-9.0.1-py3.6.egg']
# Server time: Thu, 5 Apr 2018 21:34:22 +0000
â
应用程序/模板/注册/密码\u更改\u表单。html
{% extends "base.html" %}
â
{% block title %}Change your password{% endblock %}
â
{% block content %}
<h1>Change your password</h1>
<p>Use the form below to change your password.</p>
<form action="." method="post">
{{ form.as_p }}
{% csrf_token %}
<p><input type="submit" value="Change"></p>
</form>
{% endblock %}
â
â
应用程序/模板/注册/密码\u更改\u完成。html
{% extends "base.html" %}
â
{% block title %}Password changed{% endblock %}
â
{% block content %}
<h1>Password changed</h1>
<p>Your password has been successfully changed.</p>
{% endblock %}
谢谢你的帮助!