Django-移动password_reset模板

二湾

我有以下架构:

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_confirmURL模式,而是如何为做password_reset_email模板?

马克西姆·洛兰

实际上,您可以更改template_name传递给每个django.contrib.auth视图参数password_reset视图有几个模板文件名,您可以自定义传入参数。
根据Django源代码,在您的URL模式中应该是这样的:

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章