Comments list display and sort, personal center display

Source: Internet
Author: User

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

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

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

    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

5. Each page links to a personal center

{% extends'base.html'%}    {% Block Title%} home {% Endblock%}{% Block Head%}    <script src="{{url_for (' static ', filename= ' Js/base.js ')}}"Type="Text/javascript"></script> <link href="{{url_for (' static ', filename= ' Css/base.css ')}}"Rel="stylesheet"Type="Text/css">    {% Endblock%}    {% Block main%}    {% forFooinchQuestion%}<body id="Mybody"> <div id="Gufeng"> <a href="{{url_for (' usercenter ', user_id = foo.author_id)}}">{{Foo.author.username}} comments ({{foo.comments|length}}) </a> <ulclass="List"> <li> Username: {{foo.author.username}}</li> <a href="{{url_for ("Detail", Question_id=foo.id)}}"> Title: {{Foo.title}}</a> <liclass=""> Problem: {{Foo.detail}}</li> <liclass=""> Time: {{foo.time}}</li> </ul> </div>    {% ENDFOR%}{% Endblock%}
% extends"base.html"%}{% block Title%} verbose content {% Endblock%}{% Block main%}<body bgcolor="#ffd700"> <divclass="Gufeng"> <a href="{{url_for (' usercenter ', user_id = Foo.author.id)}}">{{Foo.author.username}}</a>        {   <form action="{{url_for ('/detail/<question_id> ')}}"Method="Post">}      class='Comment'Rows="Ten"Id="Detail"Name="Detail"></textarea> <br><input type="Submit"Value="Publish"style="width:100px;height:50px;font-size:50px"> <input name="question_id"Type="Hidden"Value="{{ques.id}}"/> <p> Reviews:</p> <table border=5style="Background:gold"Width=" -"> <tr><td> Reviews Content </td></tr> <tr><td> Reviews content </td> </tr> <tr><td> Reviews Content </td></tr> </tr> </table> </div>< /body>{% Endblock%}
{% extends'base.html'%}{% Block Title%} Personal Center {% Endblock%}{% Block Head%}    <link rel="stylesheet"href="{{url_for (' static ', filename= ' Css/user.css ')}}"Type="Text/css">{% Endblock%}{% Block main%}<divclass="All question"> "{{url_for (' usercenter ', User_id=user.id)}}"> {user.username}}</a> all questions class="Wenda"style="Width:auto">          {% forFooinchUser.question%}             <liclass="Wenti"> <a href="#">{{Foo.author.username}} </a> <span>{{foo.creat_time}}</span><br> <aclass="title"href="{{url_for (' detail ', Question_id=foo.id)}}">{{foo.title}}</a><br> <p>{{foo.detail}}</p> </li>           {% ENDFOR%}      </ul></div><divclass="All Detail"> "{{url_for (' usercenter ', User_id=user.id)}}"> {user.username}}</a> all comments class="Pinglun"style="Width:auto">        {% forFooinchUser.comments%}        <liclass="Comment"> <a href="#">{{Foo.author.username}} </a> <span>{{foo.creat_time}}</span><br> <p>{{Foo.detail}}</p> </li>        {% ENDFOR%}    </ul></div><divclass="Usercenter"> "{{url_for (' usercenter ', User_id=user.id)}}"> {user.username}}</a> personal center class="Yonghu"style="Width:auto"> <li><p> User: {{user.username}}</p></li> <li><p> number: {{user.id }}</p></li> <li><p> Nickname: {{user.nickname}}</p></li> <li>&lt ;p > Article number: {{user.question|length}}</p></li> </ul></div>{% Endblock%}
@app. Route ('/usercenter/<user_id>') @loginFirstdef usercenter (user_id):    user=user.query.filter (user.id==user_id). First ()    context={        '  User': User    }    return render_template ('  center.html', **context)

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.