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

后端 未结 7 421
甜味超标
甜味超标 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:27

    Another, perhaps simpler, solution is to add your override template directory to the DIRS entry of the TEMPLATES setting in settings.py. (I think this setting is new in Django 1.8. It may have been called TEMPLATE_DIRS in previous Django versions.)

    Like so:

    TEMPLATES = [
       {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            # allow overriding templates from other installed apps                                                                                                
            'DIRS': ['my_app/templates'],
            'APP_DIRS': True,
    }]
    

    Then put your override template files under my_app/templates. So the overridden password reset template would be my_app/templates/registration/password_reset_form.html

提交回复
热议问题