1. Show All comments
{% for Foo in ques.comments%}
<ulclass= "List-group">{% for Foo in question%}<Liclass= "List-group-item"> <spanclass= "Glyphicon-leaf"Aria-hidden= "true"></span> <imgID= "Qu"src= "{{url_for (' static ', filename= ' Images/title.png ')}}"> <ahref= "#">{{Foo.author.username}} {{Foo.title}}</a> <spanclass= "badge">{{Foo.create_time}}</span> </Li>{% endfor%}</ul>
2. Sort all comments
Uquestion = db.relationship (' Question ', backref=db.backref (' comments ', order_by=creat_time.desc))
' Comments ': Comment.query.order_by (' Create_time '). All ()
3. Show number of comment bars
{{Ques.comments|length}}
<class= "tcomment"> Comments: ({{ques.comments|length}})</ span >
4. Complete the Personal center
1. Personal Center page layout (HTML files and corresponding style files)
2. Define the View function Def usercenter (user_id):
3. Passing parameters to the front-end page
4. The page displays the corresponding data
All questions and Answers released
All comments Posted
Personal information
{% extends ' index.html '%}{% block title%}usercenter {% endblock%}{% block main%}<Divclass= "Page-header"> <H3><spanclass= "Glyphicon glyphicon-user"Aria-hidden= "true"></span>{{username}}<BR> <Small>All Questions > Answers<spanclass= "badge"></span> </Small></H3> <ulclass= "List-group"style="">{% for Foo in question%}<Liclass= "List-group-item"> <spanclass= "Glyphicon glyphicon-heart-empty"Aria-hidden= "true"></span> <ahref="#">{{Foo.author.username}}</a> <spanclass= "badge">{{Foo.creat_time}}</span> <Pstyle="">{{Foo.detail}}</P> </Li>{% endfor%}</ul></Div><Divclass= "Page-header"> <H3><spanclass= "Glyphicon glyphicon-user"Aria-hidden= "true"></span>{{User}}<BR> <Small>Personal Information ><spanclass= "badge"></span> </Small></H3> <ulclass= "List-group"style="">{% for Foo in comments%}<Liclass= "List-group-item"> <spanclass= "Glyphicon glyphicon-heart-empty"Aria-hidden= "true"></span> <ahref="#">{{Foo.author.username}}</a> <spanclass= "badge">{{Foo.creat_time}}</span> <Pstyle="">{{Foo.detail}}</P> </Li>{% endfor%}</ul></Div><Divclass= "Page-header"> <H3><spanclass= "Glyphicon glyphicon-user"Aria-hidden= "true"></span>{{User}}<BR> <Small>Personal Information ><spanclass= "badge"></span> </Small></H3> <ulclass= "List-group"style=""> <Liclass= "List-group-item">User: {{username}}</Li> <Liclass= "List-group-item">Number:</Li> <Liclass= "List-group-item">Nickname:</Li> <Liclass= "List-group-item">Article article:</Li> </ul></Div>{% Endblock%}
5. Each page links to a personal center
<= "{{url_for (' usercenter ', User_id=each.author.id)}}">{{ Foo.author.username}}{{Foo.title}}</a>
Comments list display and sort, personal center display