如何更改Django管理页面上的模板? [英] how do i change templates on django admin pages?
问题描述
i am walking through this tutorial for django
在以下部分中:自定义管理员外观,在底部讨论了如何从django的默认安装中获取文件(例如:django / contrib /管理员/模板)并将其应用于您的特定网站。
in the section: Customize the admin look and feel at the bottom it talks about taking files from the default installation of django, (such as: django/contrib/admin/templates) and applying it to your specific site.
它始终指的是:
/home/my_username/mytemplates
目录,但我在任何地方都看不到。有人可以解释这个mytemplates目录在哪里。我应该创建它吗?教程的方向尚不清楚。
directory but i don't see that anywhere. Can someone explain where this mytemplates directory is. I am supposed to create it? The tutorial directions are very unclear.
推荐答案
我必须捍卫django文档的荣誉!
I must defend the honor of the django docs!
"/home/my_username/mytemplates", # Change this to your own directory.
您应该将其替换为自己的目录,无论它在哪里。
You are supposed to replace it with your own directory, wherever that might be.
是的,创建一个新目录并指向您的 settings.py
Yes, create a new directory and point to it in your settings.py
默认情况下,TEMPLATE_DIRS为空。
因此,我们在其中添加一行以告诉
Django我们的模板在哪里:
By default, TEMPLATE_DIRS is empty. So, let's add a line to it, to tell Django where our templates live:
TEMPLATE_DIRS = (
"/home/my_username/mytemplates", # Change this to your own directory. )
现在复制模板
将admin / base_site.html从Django
本身的源代码中的
默认Django管理模板
目录中
(django / contrib / admin / templates)转换为
在
TEMPLATE_DIRS中使用的
目录的管理子目录。 例如,如果您的
TEMPLATE_DIRS包含
/ home / my_username / mytemplates,如
以上,然后将
django / contrib / admin / templates / admin / base_site.html
复制到
/home/my_username/mytemplates/admin/base_site.html。
不要忘记该管理子目录。
Now copy the template admin/base_site.html from within the default Django admin template directory in the source code of Django itself (django/contrib/admin/templates) into an admin subdirectory of whichever directory you're using in TEMPLATE_DIRS. For example, if your TEMPLATE_DIRS includes "/home/my_username/mytemplates", as above, then copy django/contrib/admin/templates/admin/base_site.html to /home/my_username/mytemplates/admin/base_site.html. Don't forget that admin subdirectory.
这篇关于如何更改Django管理页面上的模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!