[CPyUG] [django模板问题]请教django模板问题

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[CPyUG] [django模板问题]请教django模板问题

Korobase
这里模板都简写了,说明用例。
1.base.html
<html>
<body>
{% block t1 %}
ttttttttttttttttttttttttttttt
{% endblock %}
</body>
</html>

2.temp.html
{% block t2 %}
<div>zzzzzzzzzzz</div>
{% endblock %}

3.index.html
{% extends "base.html" %}
{% block t1 %}
kkkkkkkkkkkkkkkkkkkkkk
{% include "temp.html" %}
{% endblock %}

4.other.html
{% extends "index.html" %}
{% block t2 %}
<div>qqqqqqqqqqqqqq</div>
{% endblock %}

问题:other.html中修改t2块,为啥不行?
谢谢!

--
"OpenBookProject"-开放图书计划邮件列表
详情: http://groups.google.com/group/OpenBookProject
维基: http://wiki.woodpecker.org.cn/

--
来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表)
发言: [hidden email]
退订: [hidden email] (向此发空信即退!)
详情: http://code.google.com/p/cpyug/wiki/PythonCn
严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
强烈: 建议使用技巧: 如何有效地报告Bug
http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html
Reply | Threaded
Open this post in threaded view
|

Re: [CPyUG] [django模板问题]请教django模板问题

金浩
只有 extends  出来的才可以覆盖吧

在 2011年6月13日 上午10:13,Korobase <[hidden email]> 写道:

> 这里模板都简写了,说明用例。
> 1.base.html
> <html>
> <body>
> {% block t1 %}
> ttttttttttttttttttttttttttttt
> {% endblock %}
> </body>
> </html>
> 2.temp.html
> {% block t2 %}
> <div>zzzzzzzzzzz</div>
> {% endblock %}
> 3.index.html
> {% extends "base.html" %}
> {% block t1 %}
> kkkkkkkkkkkkkkkkkkkkkk
> {% include "temp.html" %}
> {% endblock %}
> 4.other.html
> {% extends "index.html" %}
> {% block t2 %}
> <div>qqqqqqqqqqqqqq</div>
> {% endblock %}
> 问题:other.html中修改t2块,为啥不行?
> 谢谢!
>
> --
> "OpenBookProject"-开放图书计划邮件列表
> 详情: http://groups.google.com/group/OpenBookProject
> 维基: http://wiki.woodpecker.org.cn/
>
> --
> 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表)
> 发言: [hidden email]
> 退订: [hidden email] (向此发空信即退!)
> 详情: http://code.google.com/p/cpyug/wiki/PythonCn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> 强烈: 建议使用技巧: 如何有效地报告Bug
> http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html
>

--
来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表)
发言: [hidden email]
退订: [hidden email] (向此发空信即退!)
详情: http://code.google.com/p/cpyug/wiki/PythonCn
严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
强烈: 建议使用技巧: 如何有效地报告Bug
        http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html
Reply | Threaded
Open this post in threaded view
|

Re: [CPyUG] [django模板问题]请教django模板问题

SanCao Jie
要用 extends
而且 extends要放在文件开头

On 6/13/11, 金浩 <[hidden email]> wrote:

> 只有 extends  出来的才可以覆盖吧
>
> 在 2011年6月13日 上午10:13,Korobase <[hidden email]> 写道:
>> 这里模板都简写了,说明用例。
>> 1.base.html
>> <html>
>> <body>
>> {% block t1 %}
>> ttttttttttttttttttttttttttttt
>> {% endblock %}
>> </body>
>> </html>
>> 2.temp.html
>> {% block t2 %}
>> <div>zzzzzzzzzzz</div>
>> {% endblock %}
>> 3.index.html
>> {% extends "base.html" %}
>> {% block t1 %}
>> kkkkkkkkkkkkkkkkkkkkkk
>> {% include "temp.html" %}
>> {% endblock %}
>> 4.other.html
>> {% extends "index.html" %}
>> {% block t2 %}
>> <div>qqqqqqqqqqqqqq</div>
>> {% endblock %}
>> 问题:other.html中修改t2块,为啥不行?
>> 谢谢!
>>
>> --
>> "OpenBookProject"-开放图书计划邮件列表
>> 详情: http://groups.google.com/group/OpenBookProject
>> 维基: http://wiki.woodpecker.org.cn/
>>
>> --
>> 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表)
>> 发言: [hidden email]
>> 退订: [hidden email] (向此发空信即退!)
>> 详情: http://code.google.com/p/cpyug/wiki/PythonCn
>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>> 强烈: 建议使用技巧: 如何有效地报告Bug
>> http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html
>>
>
> --
> 来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表)
> 发言: [hidden email]
> 退订: [hidden email] (向此发空信即退!)
> 详情: http://code.google.com/p/cpyug/wiki/PythonCn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> 强烈: 建议使用技巧: 如何有效地报告Bug
>         http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html
>

--
来自: python-cn`CPyUG`华蟒用户组(中文Python技术邮件列表)
发言: [hidden email]
退订: [hidden email] (向此发空信即退!)
详情: http://code.google.com/p/cpyug/wiki/PythonCn
严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
强烈: 建议使用技巧: 如何有效地报告Bug
        http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html