- 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
<h4>Comment: ({{quest.comment|length}})</h4>{% for Foo in comments%}<Divclass= "List-group"> <ahref=""class= "List-group-item Active">{{Foo.author.username}}</a> <Divclass= "List-group-item"> <ahref=""class= "List-group-item-heading"> </a> <Pclass= "List-group-item-text">{{Foo.detail}}</P> </Div> <Divclass= "List-group-item"> <spanclass= "badge">Release time: {{foo.creat_time}}</span>Release Time</Div> </Div>{% endfor%}
classComment (db. Model):__tablename__='Comment'ID= db. Column (db. Integer, Primary_key=true, autoincrement=True) author_id= db. Column (db. Integer, Db. ForeignKey ('user.id')) question_id= db. Column (db. Integer, Db. ForeignKey ('question.id')) Creat_time= db. Column (db. DateTime, default=datetime.now) Detail= db. Column (db. Text, nullable=False) Question= Db.relationship ('ques', Backref=db.backref ('Comment', order_by=Creat_time.desc)) Author= Db.relationship ('User', Backref=db.backref ('Comment'))
<Divclass= "Container"> <Divclass= "Row Clearfix"> <Divclass= "col-md-2 column"> <H2>All questions</H2> <Divclass= "List-group">{% for Foo in questions%}<Divclass= "List-group-item">title: {{Foo.title}}</Div> <Divclass= "List-group-item"> <Pclass= "List-group-item-text">content: {{foo.detail}}<spanclass= "badge">{{Foo.creat_time}}</span> </P> </Div>{% endfor%}</Div> </Div> <Divclass= "col-md-6 column"> <H2>All reviews</H2> <Divclass= "Panel Panel-default">{% for Foo in comments%}<Divclass= "Panel-heading"> <H3class= "Panel-title">{{Foo.detail}}</H3> </Div> <Divclass= "Panel-body">{Foo.create_time}</Div> <Divclass= "Panel-footer">Panel Footer</Div>{% endfor%}</Div> </Div> <Divclass= "col-md-4 column"> <Divclass= "Panel Panel-default"> <Divclass= "Panel-heading"> <H3class= "Panel-title">{{Username.username}}</H3> </Div> <Divclass= "Panel-body">Panel Content</Div> <Divclass= "Panel-footer">Panel Footer</Div> </Div> </Div> </Div></Div>
Comments list display and sort, personal center display