自定义base_site.html在Django中不工作 [英] Custom base_site.html not working in Django

查看:121
本文介绍了自定义base_site.html在Django中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Nitrous 玩Django框架。在教程2 中显示了如何更改base_site.html模板。我在TEMPLATE_DIRS =()中添加了一行新行:


'home / action / workspace / mysite / templates' p>

在base_site.html中,我将Django管理的站点名称改为管理:


{%trans'管理'%}


但是我仍然看不到网站上的更改。我尝试了不同的TEMPLATE_DIRS,如:


'〜/ workspace / mysite / templates',



'home / action / workspace / mysite /',



'home / action / workspace / mysite / templates /',


并重新启动服务器。但是我做错了事情。

解决方案

请注意,这个答案是在 TEMPLATES 设置在Django 1.8中引入。



本教程说您应该创建一个 admin / home / action / workspace / mysite / templates / admin

  TEMPLATE_DIRS =(
'/ home / action / workspace / mysite / templates',

请注意 / home /...之前的斜线,以及尾部的逗号,使其成为一个元组。


I am using Nitrous for playing with the Django framework. In tutorial 2 is shown how to change the base_site.html template. I've added in the TEMPLATE_DIRS = ( ) a new line:

'home/action/workspace/mysite/templates',

And in base_site.html I changed the site name title of Django Administration into Administration:

{% trans 'Administration' %}

But I still see no changes on the website. I've tried different TEMPLATE_DIRS like:

'~/workspace/mysite/templates',

'home/action/workspace/mysite/',

'home/action/workspace/mysite/templates/',

And restarting the server. But I am doing something wrong.

解决方案

Note that this answer was written before the TEMPLATES setting was introduced in Django 1.8.

The tutorial says you should create an admin subdirectory inside your template directory, and put your template inside that.

Try with base_site.html in /home/action/workspace/mysite/templates/admin and with

TEMPLATE_DIRS = (
    '/home/action/workspace/mysite/templates',
)

Note the slash before /home/... and the trailing comma to make it a tuple.

这篇关于自定义base_site.html在Django中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆