我有以下架构:
Project/
templates/
aaa/ #This is my application main templates folder
registration/
password_reset_complete.html
password_reset_form.html
password_reset_email.html
password_reset_confirm.html
aaa/
我想移动password_reset
模板文件并销毁registration
文件夹以获得以下架构:
Project/
templates/
aaa/ #This is my application main templates folder
password_reset_complete.html
password_reset_form.html
password_reset_confirm.html
mails/
password_reset_email.html
aaa/
我想我可以覆盖password_reset_complete
,password_reset_form
,password_reset_confirm
网址格式,但如何处理password_reset_email
模板?
答案 0 :(得分:1)
实际上,您可以更改传递给每个template_name
视图的django.contrib.auth
参数。 password_reset
视图在参数中传递了几个模板文件名,您可以自定义
根据{{3}},在您的网址格式中应该是这样的:
(r'^accounts/reset_password/$',
'django.contrib.auth.views.password_reset',
{'template_name': 'aaa/password_reset_form.html',
'email_template_name': 'mails/password_reset_email.html'}),
(r'^accounts/reset_confirm/$',
'django.contrib.auth.views.password_reset_confirm',
{'template_name': 'aaa/password_reset_confirm.html'}),
(r'^accounts/reset_complete/$',
'django.contrib.auth.views.password_reset_complete',
{'template_name': 'aaa/password_reset_complete.html'}),