我想把django auth的密码更改模板主题化到我的站点。问题是django看到的是模板的django/contrib/admin/templates/registration/
版本,而不是我精心制作的myapp/template/registration/password*.html
。在
This海报被告知在设置.py,这对我来说有点脆弱。我想this海报可能得到了一个合理的答案,但如果是这样的话,我还没有完全理解它。在
所以我做的就是在我的urls.py
文件中添加一堆非干性垃圾,从auth_urls.py
复制:
# Provide explicit templates where I've provided them, shadowing the URL's
# that registration.backends.defaults.urls will provide.
url(r'^accounts/password/change/$',
auth_views.password_change,
{'post_change_redirect': reverse_lazy('auth_password_change_done'),
'template_name': 'registration/password/change_form.html' },
name='auth_password_change'),
# ...
url(r'^accounts/', include('registration.backends.default.urls')),
这是可行的,但让我难过的是它的重复。当然,django鼓励一些更清洁的东西。有什么建议吗?在
(Fwiw、django 1.7和python3.4.2。)
将此模板放入项目的
templates
目录,并将以下代码添加到settings.py
。在默认情况下,
django.template.loaders.filesystem.Loader
放在TEMPLATE_LOADERS
中的django.template.loaders.app_directories.Loader
之前,所以project的templates
目录优先于app的templates
。在相关问题 更多 >
编程相关推荐