- Show All comments
{% for Foo in ques.comments%}
- All comments Sorted
Uquestion = db.relationship (' Question ', backref=db.backref (' comments ', order_by=creat_time.desc))
- Show number of comment bars
{{Ques.comments|length}}
- 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
5. Each page links to a personal center
@app. Route ('/usercenter/<user_id> ') def usercenter (user_id): user = User.query.filter (user.id = = user_id). First () context = { ' username ': user.username, ' Wenda ': User.wenda, ' comments ': User.comment } return render_template (' usercenter.html ', **context)
{% block switchbody%}<div class= "container" > <div class= "Row Clearfix" > <div class= "col-md-4 Col Umn "> </div> <div class=" col-md-4 column "> {% for foo in Wenda%} < div class= "Panel panel-default" > <div class= "panel-heading" > {% extends ' switch.html '%} {% block usercentertitle%} Personal Center {% Endblock%}{% block Usercenterhead%}{% endblock%}{% block switchbody%} <div CLA ss= "col-md-6 column" > <div class= "Page-header" > {% for foo in Wenda%} <div class= "Panel PA Nel-default "> <div class=" panel-heading "> Comments list display and sort, personal center display