django的模版标签和过滤器
来源:互联网 发布:java byte赋值0xff 编辑:程序博客网 时间:2024/06/07 06:33
python manage.py shellfrom django import template
if标签的使用
t = template.Template(‘{%if a%}A is true{%else%}A is False{%endif%}')t.render(template.Context({‘a’:True}))
for标签的使用
t = template.Template('{%for i in items%}<li>{{i}}</li>{%endfor%}')t.render(template.Context({‘items’:[1,3,4,5,6,6]}))
过滤器的使用:
t = template.Template(‘{{a|lower]}’).render(template.Context({‘a’:’CCCAB'}))t = template.Template(‘{{a|upper]}’).render(template.Context({‘a’:’CCCAB'}))t = template.Template(‘{{a|first]}’).render(template.Context({‘a’:’CCCAB'}))t = template.Template(‘{{a|last]}’).render(template.Context({‘a’:’CCCAB'}))t = template.Template(‘{{a|truncatechars:3]}’).render(template.Context({‘a’:’CCCAB'}))t = template.Template(‘{{a|truncatewords]}’).render(template.Context({‘a’:’CCCAB'}))
0 0
- django的模版标签和过滤器
- django 自定义标签和过滤器
- django 内置标签和过滤器
- Python Django进阶教程(二)(模版过滤器,标签)
- Django 内建的模板标签和过滤器
- django内建的模块标签和过滤器
- django 内建标签和过滤器参考
- 自定义Django模板过滤器和标签
- django 自定义模板标签和过滤器
- Django自定义模板过滤器和标签
- django 自定义模板标签和过滤器
- Django-模板(内置标签和过滤器)
- django--模版系统-标签的自定义
- django 模板标签 过滤器
- django 模板标签 过滤器
- django自定义标签和自定义过滤器的作用演示和区别
- django--模版系统-过滤器的自定义,两种加载模版(template)的方法
- 从头学习开发Django系列-自定义标签和过滤器
- 第40讲项目3——鸡兔共笼
- 关于SPI的隔离
- 从无头单链表中删除节点
- 15 款很棒的文本编辑器
- 杭州电子科技大学(HDU)ACM 刷题----------字符串之2026
- django的模版标签和过滤器
- 链表排序
- 单例模式的优缺点
- 交叉墒
- nyoj1237
- 算法系列笔记7(有关图的算法一—搜索,拓扑排序和强连通分支)
- Go语言的类型结构
- Mybatis接口映射,嵌套查询
- HDU 3879 Base Station 最小割