2009-01-15 58 views
8

我想重写Django的管理“更改密码”页面(change_password.html)。因此,我在我的项目的“/templates/admin/registration/password_change_form.html”目录中放置了Django的“/contrib/admin/templates/registration/password_change_form.html”。不幸的是,这似乎没有办法。如何覆盖Django的管理更改密码页面?

在这一点上,我很难过。我猜它与Django的/contrib/auth/urls.py文件(它将管理员更改密码调用指向“django.contrib.auth.views.password_change”)有关,但管理员模板更改已微不足道到目前为止,我很惊讶这个不跟风。

有什么想法?

+0

什么是您的settings.TEMPLATE_DIRS样子? – bchhun 2009-01-15 16:42:18

+0

它有''./templates',“。我不确定这是什么问题。我有一个“/ templates/admin”目录,这在TEMPLATE_DIRS – Huuuze 2009-01-15 16:48:43

回答

6

快速查看源表示你应该把模板:

/templates/registration/password_change_form.html 

注好处:没有“管理员/”在那里。

+0

中没有明确定义。你认为这个解决方案在哪里?我一定忽略了它。 – Huuuze 2009-01-15 16:51:38

1

我有同样的问题;我相信它必须做django模板加载器如何工作。

如果你正在使用类似

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

的东西,如 TEMPLATE_DIRS =( os.path.join(PROJECT_DIR, '模板'), )

然后,你会期望( localstore是你本地的satchmo覆盖的名字)localstore/templates/registration/password_change_form.html会起作用。但是,它不适用于password_change_form,因为管理员正在覆盖它。因此,它会是这样的:

  1. 文件加载模板迪尔斯(如模板)
  2. (Django管理模板)
  3. 本地应用程序模板迪尔斯

所以,对我来说,解决办法是将我的注册模板覆盖从我的localstore/templates目录移动到项目的/ templates目录。