How do I use the built in password reset/change views with my own templates

后端 未结 7 430
甜味超标
甜味超标 2020-11-29 16:08

For example I can point the url \'^/accounts/password/reset/$\' to django.contrib.auth.views.password_reset with my template filename in the contex

7条回答
  •  余生分开走
    2020-11-29 16:44

    You just need to wrap the existing functions and pass in the template you want. For example:

    from django.contrib.auth.views import password_reset
    
    def my_password_reset(request, template_name='path/to/my/template'):
        return password_reset(request, template_name)
    

    To see this just have a look at the function declartion of the built in views:

    http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/views.py#L74

提交回复
热议问题