无法更改默认的django模板

无法更改默认的django模板,django,django-templates,Django,Django Templates,我正在学习Django的教程- 最后,他们要求我们通过以下步骤将默认网页模板的名称从“Django Administration”更改为其他名称。 1) 将base_site.html从django的默认文件夹复制到TEMPLATE_DIRS中指定的admin目录。 目前我的模板目录看起来像- TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".

我正在学习Django的教程- 最后,他们要求我们通过以下步骤将默认网页模板的名称从“Django Administration”更改为其他名称。 1) 将base_site.html从django的默认文件夹复制到TEMPLATE_DIRS中指定的admin目录。 目前我的模板目录看起来像-

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"/home/mysite/polls/mytemplates"
)
我还将管理模板目录复制到/home/mysite/polls/mytemplates

结构是这样的 /主页/mysite/polls/mytemplates/admin 其中admin文件夹包含base.html和base_site.html

我已经在base_site.html文件中编辑了标题,但当我运行django时,它仍然会显示默认的模板标题


有人能告诉我我遗漏了什么吗?

您的模板目录中不应该有您的应用程序名。Django将自动添加名为
模板
的任何目录,该目录是
已安装应用程序
中列出的任何应用程序的一部分。这就是为什么您的自定义管理模板不起作用

您应该做的第一件事是将
/home/mysite/polls/mytemplates
重命名为
模板

mv /home/mysite/polls/mytemplates /home/mysite/polls/templates
接下来,您应该:

TEMPLATE_DIRS = ('/home/mysite/templates',)
然后,您的管理员模板应该位于
/home/mysite/templates/admin/

至于逗号:括号中的单个字符串只是一个字符串,但有了逗号它就变成了一个元组。
TEMPLATE\u DIRS
设置是一个元组,这就是为什么需要额外的逗号:

>>> a = ('hello')
>>> type(a)
<type 'str'>
>>> a = ('hello',)
>>> type(a)
<type 'tuple'>
>a=('hello')
>>>类型(a)
>>>a=(‘你好’,)
>>>类型(a)

我想出来了。问题是我在我的网站名称中有一个引用。因此,我们不得不将整个站点名称用双引号括起来,而不是用一个引号括起来。

您是否可以检查
django.template.loaders.filesystem.Loader
是否在
template\u loaders
设置中位于第一位。@tuxcanfly是的。是的。检查以下模板加载程序=('django.TEMPLATE.LOADERS.filesystem.Loader','django.TEMPLATE.LOADERS.app_directories.Loader','django.TEMPLATE.LOADERS.eggs.Loader',)缺少逗号:
“/home/mysite/polls/mytemplates”,
@BurhanKhalid-添加逗号。仍然无法工作我将其重命名为templates TEMPLATE_DIRS=('/home/mysite/templates',)Admin文件夹位于/home/mysite/templates/。但它仍然不起作用:(