标签:
//过滤器格式为: 变量 | upper(过滤器关键字)
1、index
<html>
<head>
<title>DOcument</title>
</head>
<body>
<h1>{{user}}</h1>
</br>
</br>
<h1>过滤器</h1>
{% for book in user reversed %}
<li>{{book | upper}}</li>
{% empty %}
<li>没有找到书籍</li>
{% endfor %}
</body>
</html>
# -*- coding: cp936 -*- from django.http import HttpResponse from django.template import loader,Context def index(request): t=loader.get_template(‘index.html‘) bookList=[‘python‘,‘C++‘,‘java‘,‘php‘] #向html页面传递数据 c=Context({‘user‘:bookList}) #渲染方法 t=t.render(c) return HttpResponse(t)
标签:
原文地址:http://www.cnblogs.com/dengyg200891/p/5096764.html