模板加载器找不到/registration/password_reset_form.html

时间:2016-12-14 11:44:34

标签: python html django templates

使用django(1.8)的内置 password_rest视图,我遇到了一个奇怪的问题。在文档中,他们说模板名称默认为 registration / password_reset_form.html 。牢记这一点,我没有在我的 urls.py 中提供任何模板名称,认为django将加载默认模板。这是我的密码重置网址

urls.py

url(r'^password_reset$', auth_views.password_reset, name='password_reset'),

当我点击忘记密码链接时,

<p><a href={% url 'password_reset' %}> Forgot your password?</a></p>

执行password_rest视图,我收到Template DoesNotExist错误,下面是错误信息

TemplateDoesNotExist at /accounts/password_reset
registration/password_reset.html

Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/vinothkumar/github/djtest/templates/registration/password_reset.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/home/vinothkumar/github/djtest/venv_new/lib/python3.4/site-packages/django/contrib/admin/templates/registration/password_reset.html (File does not exist)
/home/vinothkumar/github/djtest/venv_new/lib/python3.4/site-packages/django/contrib/auth/templates/registration/password_reset.html (File does not exist)
/home/vinothkumar/github/djtest/accounts/templates/registration/password_reset.html (File does not exist)

我的问题是为什么模板加载器正在寻找 /registration/password_reset.html 而不是加载默认的 /registration/password_reset_form.html

我为 password_reset_done 尝试了相同的方法,在这种情况下,它会加载默认模板 /registration/password_reset_done.html 。一切都很好。

0 个答案:

没有答案