模板标签

一对花括号和百分号包围的文本(如{% if ordered_warranty %} )是模板标签。

标签的定义相当宽泛:只要能让模板系统"做些事"的就是标签。

node2:/tlcb/mysite/polls/templates/polls#cat notice.html
{% if count > 5 %}
<p>111111111111111111111111111</p>
{% else %}
<p>2222222222222222222222222
</p>
{% endif %}


def notice(req):
   #return render_to_response('polls/notice.html')
   #    return render(request, 'cmdb/year_archive.html', {
   #     'foo': aaaa,
   # })
   return render(req,'polls/notice.html',{'count':1}
   
http://192.168.137.3:9000/notice/

2222222222222222222222222

原文地址:https://www.cnblogs.com/hzcya1995/p/13349273.html