您的位置:首页 > 编程语言 > Go语言

django后台页面标题定制

2016-01-16 20:52 459 查看
创建templates文件夹:
并将Django源代码包的django/contrib/admin/templates文件夹下复制一个叫base_site.html的文件到admin文件夹下:
mysite/
├── db.sqlite3
├── manage.py
├── mysite
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── templates
└── admin
└── base_site.html
修改setting.py templates路径
添加templates目录路径:支持绝对路径、相对路径、或者 os.path.join(BASE_DIR,'templates'),
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'DIRS': ['/root/l/mysite/templates/',], #django 1.9 templates写这里
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]


修改base_site.html如下:如果不支持utf-8可能中文会乱码
{% extends "admin/base.html" %}
{% block title %}{{ title }} | DannySite 后台管理{% endblock %}
{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">LannyMa后台管理</a></h1>
{% endblock %}
{% block nav-global %}{% endblock %}


本文出自 “LannyMa” 博客,请务必保留此出处http://lannyma.blog.51cto.com/4544390/1735648
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: