1. Comments {% extends"myweb.html"%}{% block Detailtitle%} Quiz details {% Endblock%} {% Block Detailhead%}{% Endblock%} {% Block Mywebbody%} <divclass="Page-header"style="Color:black"align="Center"> class="badge">{{ques.creat_time}}</span> </small>class=" Lead">{{ques.detail}}</p> "{{url_for (' comment ')}}"Method="Post">Please comment<divclass="Form-group"> <textareaname="new_comment"class="Form-control"Rows="3"Id="new-comment"Placeholder=""></textarea> <input type="Hidden"Name="question_id"Value="{{ques.id}}"> </div> <buttontype="Submit"class="btn Btn-default"> Send </button> </form> class="List-group"style="margin:10px"> {% forFooinchQues.comments%} <liclass="List-group-item"> <spanclass="Glyphicon Glyphicon-heart-empty"aria-hidden="true"></span> <a href="{{url_for (' usercenter ', User_id=foo.author.id)}}">{{foo.author.username}}</a> <spanclass="badge">{{foo.creat_time}}</span> <p style="">{{foo.detail}}</p> </li>{% ENDFOR%} </ul> {% Endblock%} define Usercenter@app.route ('/usercenter/<user_id>') @loginfirstdefUsercenter (user_id): User=user.query.filter (user.id==user_id). First () Mycontext={ 'username': User.username,'Questions': User.question,'Comments': User.comments,} returnrender_template ('usercenter.html',**mycontext) Personal Center {% extends'myweb.html'%}{% block title%} Personal Center {% endblock%}{% Block main%} <divclass="Page-header"> class="Glyphicon Glyphicon-user"aria-hidden="true"></span>{{username}}<br> <small> all questions and Answers ><spanclass="badge"></span> </small>class="List-group"style=""> {% forFooinchUser.question%} <liclass="List-group-item"> <spanclass="Glyphicon Glyphicon-heart-empty"aria-hidden="true"></span> <a href="#">{{foo.author.username}}</a> <spanclass="badge">{{foo.creat_time}}</span> <p style="">{{foo.detail}}</p> </li> {% ENDFOR%} </ul></div> <divclass="Page-header"> class="Glyphicon Glyphicon-user"aria-hidden="true"></span>{{User}}<br> <small> Personal Information ><spanclass="badge"></span> </small>class="List-group"style=""> {% forFooinchUser.comments%} <liclass="List-group-item"> <spanclass="Glyphicon Glyphicon-heart-empty"aria-hidden="true"></span> <a href="#">{{foo.author.username}}</a> <spanclass="badge">{{foo.creat_time}}</span> <p style="">{{foo.detail}}</p> </li> {% ENDFOR%} </ul></div> <divclass="Page-header"> class="Glyphicon Glyphicon-user"aria-hidden="true"></span>{{User}}<br> <small> Personal Information ><spanclass="badge"></span> </small>class="List-group"style=""> <liclass="List-group-item"> User:{{username}}</li> <liclass="List-group-item"> Ref.:</li> <liclass="List-group-item"> Nickname:</li> <liclass="List-group-item"> Article Article:</li> </ul></div> {% Endblock%}
Comments list display and sort, personal center display