虽然它确实存在,但是“TemplateDoesNotExist”错误

时间:2018-06-05 06:40:53

标签: django

我写了密码重置并更改了结构为

的模板
    In [10]: !tree /Users/me/desktop/Django/forum/user/templates/user
    /Users/me/desktop/Django/forum/user/templates/user
    ├── activate.html
    ├── failure.html
    ├── logged_out.html
    ├── login.html
    ├── password_change_done.html
    ├── password_change_form.html
    ├── password_reset_complete.html
    ├── password_reset_confirm.html
    ├── password_reset_done.html
    ├── password_reset_email.html
    ├── password_reset_form.html
    ├── password_reset_subject.txt
    ├── register.html
    ├── success.html
    └── validate.html

我在浏览器中测试时会抛出TemplateDoesNotExist错误 http://127.0.0.1:8001/user/password_reset/

    TemplateDoesNotExist at /user/password_reset/
    /user/password_reset_form.html
    Request Method: GET
    Request URL:    http://127.0.0.1:8001/user/password_reset/
    Django Version: 1.11.13
    Exception Type: TemplateDoesNotExist
    Exception Value:    
    /user/password_reset_form.html

所有的密码_ _ 都没有按预期执行,但其他的功能正常。

enter image description here

urls.py

#Costomize the authentication system
urlpatterns = [
    # show the register page
    url(r"^register/$", views.register, name="register"),
    ...
    url(r'^password_reset/$', auth_views.PasswordResetView.as_view(template_name="/user/password_reset_form.html"), name='password_reset'),
        ]

我的多个密码模板有什么问题?

1 个答案:

答案 0 :(得分:1)

您的模板名称应为user/password_reset_form.html

检查here