Comments list display and sort, personal center display

Source: Internet
Author: User

1. Show All comments
{% for Foo in ques.comments%}

1<ulclass="List-group"style="margin-top:30px;">23{% forCominchComment%}4<liclass="List-group-item"style="width:800px">5<aclass="wrap-img"href="#"target="_blank">6"http://www.bookmarkye.com/3.jpg"Width="50px">7</a>8<spanclass="Glyphicon Glyphicon-left"aria-hidden="true"></span>9<a href="{{url_for (' comment ', User_id=com.author.id)}}"Tentarget="_blank">{{Com.author.username}}</a> One<br> A<spanclass="badge">{{Com.creat_time}}</span> -<p style="">{{Com.detail}}</p> -</li> the{% ENDFOR%} -</ul>

2. Sort all comments
Uquestion = db.relationship (' Question ', backref=db.backref (' comments ', order_by=creat_time.desc))

1<ulclass="List-group"style="">23{% forFooinchQuestions%}4<liclass="List-group-item"style="width:800px">5<aclass="wrap-img"href="#"target="_blank">6"http://www.bookmarkye.com/3.jpg"Width="50px">7</a>8<spanclass="Glyphicon Glyphicon-left"aria-hidden="true"></span>9<a href="{{url_for (' comment ', User_id=foo.author.id)}}"Tentarget="_blank">{{Foo.author.username}}</a> One<br> A<a href="{{url_for (' detail ', Question_id=foo.id)}}">{{Foo.title}}</a> -<spanclass="badge">{{Foo.creat_time}}</span> -<p style="">{{Foo.detail}} the</p> -</li> -{% ENDFOR%} -</ul>

3. Show number of comment bars
{{Ques.comments|length}}

1            <Divclass= "List-group-item"style= "margin-top:30px;width:800px;">2                     <H1>Name:<Small>{{User.username}}</Small></H1>3                     <H1>Number of questions:<Small>{{Questions|length}}</Small></H1>4                     <H1>Number of comments:<Small>{{Comment|length}}</Small></H1>5                 </Div>

4. Complete the Personal center

  1. Personal Center page layout (HTML files and corresponding style files)

  

1 <Linkrel= "stylesheet"href= "Http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">2     <Scriptsrc= "Http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></Script>3     <Scriptsrc= "Http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></Script>

2. Define the View function Def usercenter (user_id):

1 #all comments posted by a user2@app. Route ('/comment/<user_id>', methods=['GET','POST'])3 defComment (user_id):4user = User.query.filter (user.id = =user_id). First ()5Content = {6         'Comment': User.comment,7         'Questions': User.question,8         'User2': User9     }Ten     returnRender_template ('comment.html', **content)

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

      

Comments list display and sort, personal center display

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.