django 未找到“password_reset_confirm”的反向,“password_reset_confirm”不是有效的视图函数或模式名称,误差,误差

bwitn5fc  于 2023-08-08  发布在  Go
关注(0)|答案(3)|浏览(100)

我想在我的网页上实现密码重置功能,但我得到NoReverseMatch at /accounts/password_reset/ Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name.错误。请帮我解决这个错误
url.py代码:

app_name="accounts"
urlpatterns=[

path('password_reset/', auth_views.PasswordResetView.as_view(template_name="password_reset.html",success_url=reverse_lazy('accounts:password_reset_done')), name='password_reset'),

  path('password_reset_done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),

 path('reset/<uidb64>/<token>/',    auth_views.PasswordResetConfirmView.as_view(template_name="password_reset_confirm.html",success_url=reverse_lazy('accounts:password_reset_complete')), 
 name="password_reset_confirm"),

path('reset_password_complete/', 
    auth_views.PasswordResetCompleteView.as_view(template_name="password_reset_done.html"), name="password_reset_complete"),

字符串
]
passwrd_reset.html

{% extends 'base.html' %}
{% block title %}Password Reset Page{% endblock %} 
{% load crispy_forms_tags %}
{% block body %}
<div class="container">
<div class="row mt-5 pt-3">
    <div class="col-md-8 offset-md-2">
        <div class="card my-3 shadow">
            <div class="card-body">
<h4>Password Reset Page</h4>
                <hr>
                <div class="alert alert-info">
                    Enter email and a mail will be sent with instructions to reset password
                </div>
                <form method="POST">
                    {% csrf_token %}
                    {{ form|crispy }}
                    <input class="btn btn-primary btn-block" type="submit" value="Reset Password">
 </form>
                <hr>
            </div>
        </div>
    </div>
</div>

{% endblock body%}
关于我的应用程序的附加信息我有两个应用程序,一个是 Jmeter 板,另一个是帐户,我想在我的帐户应用程序实现这一点

zvms9eto

zvms9eto1#

在您的core应用程序中(您有settings.py)。转到urls.py文件并粘贴:

path('', include('django.contrib.auth.urls'))

字符串
注意,必须从django.urls导入include

7vux5j2d

7vux5j2d2#

1.导航到与settings.py位于同一文件夹中的主 url.py
1.从django.urls导入include(从django.urls导入include
1.将下面一行添加到urlpatternspath('',include('django.contrib.auth.urls')),
重新加载服务器并重试

jhkqcmku

jhkqcmku3#

请检查html文件名。是否有密码_reset_confirm. html文件?

相关问题