Django - 移动password_reset模板

时间:2014-06-02 07:57:22

标签: django url django-templates django-registration

我有以下架构:

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_completepassword_reset_formpassword_reset_confirm网址格式,但如何处理password_reset_email模板?

1 个答案:

答案 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'}),