con lock turn if条件 ndb temp name ... simple
在Templates中添加母版:
- 母版...html
母版(master.html)中可变化的地方加入:
- {%block content%}{%endblock%}
在子版 (usermg.html) 中设置如下:
- { % extends‘master.html‘ %
- } { % block content %
- } < h1 > 用户管理 < /h1>
- {%end block%}/
导入小组件的模块:
- { % include‘model.html‘ %
- }#同样会载入model.html中的模板语言
自定义模板语言函数simple_tag:
- {{ name|lower}} #lower函数让name全部小写
新建templatetags文件夹,创建函数文件xxxx.py:
- from django import template
- from django.utils.safestring import mark_safe
- register = template.Library()
(1)simple_tag (不能作为if条件,参数任意)
- @register.simple_tag
- def func_test(a):
- return a
在html中引入:
- {% load xxxx %}
- {% func_test a %}
Django中的模板和分页
con lock turn if条件 ndb temp name ... simple
原文:http://www.cnblogs.com/crazytao/p/7786968.html
来源: http://www.bubuko.com/infodetail-2381325.html