<HTML> <Head> <title>DOcument</title> </Head> <Body> <H1>{{User}}</H1> </BR> </BR> <H1>Filter filters</H1> <P>1, the use of the Linux pipeline thinking</P> <P>2, first the value of book into uppercase, and then converted to lowercase, and then converted to uppercase letters</P>{% for book in user%}<Li>{{book | upper |lower | capfirst}}</Li>{% empty%}<Li>No books found</Li>{% endfor%}</Body></HTML>
#-*-coding:cp936-*- fromDjango.httpImportHttpResponse fromDjango.templateImportLoader,contextclassPerson ():def __init__(self,name,age,sex): Self.name=name Self.age=Age Self.sex=SexdefSay (self):return 'My name is'+Self.namedefIndex (Request): T=loader.get_template ('index.html') Person=person ('Deng', 17,'female') Booklist=['python','C + +','Java','PHP'] #booklist=[]dict={' Age': 25,'Yuyan':'python','where':' China','name':'Xiaodeng','Sex':'male'} #passing data to an HTML pageC=context ({'User': Booklist}) #Rendering Methodst=T.render (c)returnHttpResponse (t)
Django Definition Template Syntax 06 (filter multiple Filter)