【问题标题】:django-registration password reset custom template not loadingdjango-registration 密码重置自定义模板未加载
【发布时间】:2012-11-15 16:44:02
【问题描述】:

我正在使用 django-registration 注册用户,但是当我想使用自己的模板进行密码重置时,我得到的是管理员模板,而不是我创建的模板。我的模板位于 myapp/templates/registration/password_reset_form.html 中,并且我的模板加载器已正确设置:

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    )

我可能会错过什么?

我正在使用 Django 1.4

【问题讨论】:

    标签: django django-registration


    【解决方案1】:

    难道django.contrib.auth 在您的INSTALLED_APPS 中出现在myapp 之前?这意味着 django 首先找到原始模板并使用这个模板。更多信息请参阅文档:https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types

    【讨论】:

    • 我不认为是这样,根据文档,TEMPLATE_LOADERS 说明首先查找模板的位置
    • 没错。但是 app_directories.Loader 会找到 django.contrib.auth 模板和您自定义的模板。因为它们都是 django 的同等应用程序。这意味着首先声明的应用程序模板将首先加载。但当然前提是您没有定义 TEMPLATE_DIRS 设置。
    • 我尝试重新排列已安装的应用程序,它现在可以工作了.. 所以我承认你的回答......但这很奇怪,因为我确实定义了 TEMPLATE_DIRS
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-02
    • 2016-04-21
    • 2016-02-25
    • 1970-01-01
    • 2019-01-16
    • 1970-01-01
    相关资源
    最近更新 更多