首页 文章

Django 1.6 - 密码更改/重置模板

提问于
浏览
5

我想使用django的密码更改/重置视图,例如视图

django.contrib.auth.views.password_change

我需要创建一个名为的模板

registration/password_change_form.html

问题是即使我在我的项目中实现了这个模板,django仍然显示管理网站的密码更改页面,我可以让django使用我的模板的唯一方法是将其重命名为不同的东西 - 例如registration / password_change_form_1 .html然后传递名称

url(r'^password/change/$',
    auth_views.password_change,
    {'template_name': 'registration/password_change_form_1.html',
     'password_change_form': MyPasswordChangeForm},
    name='password_change'),

我在这里错过了什么吗?当我使用默认名称时,为什么django不会使用我的模板?

3 回答

  • 0

    我认为因为你的应用程序在 INSTALLED_APPdjango.contribute.admin 下 .

  • 7

    Django使用默认名称自动生成管理模板,因此,如果使用admin,则必须指定其他模板名称 .

    它根本无法找到您的模板,因为它被生成的模板覆盖 .

  • 0

    添加设置

    INSTALLED_APPS = (
        ...
        'registration',
    )
    

    TEMPLATE_DIRS = (
        ...
        "/home/user/templates",
    )
    

    添加将包含模板和其他模板的目录模板“ registrationbase.html

    在django中运行== 1.5

相关问题