Comments list display and sort, personal center display

Source: Internet
Author: User
Tags button type

    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

@app. Route ('/usercenter/<user_id>') @loginFirstdefUsercenter (user_id): User=user.query.filter (user.id==user_id). First () Context={        'username': User.username,'Questions': User.questions,'Comments': user.comments}returnRender_template ('usercenter.html', **context)

{% 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="margin:10px">            {% forFooinchQuestion%}                <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>{{foo.detail}}</p> </li>            {% ENDFOR%}        </ul> </div> <divclass="Page-header"> class="Glyphicon Glyphicon-user"aria-hidden="true"></span>{{user}}<br> <small> all reviews <spanclass="badge"></span></small> class="List-group"style="margin:10px">            {% forFooinchComments%}                <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>{{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="margin:10px"> <liclass="List-group-item"> User: {{username}}</li> <liclass="List-group-item"> Ref.:</li> <liclass="List-group-item"> Nickname:</li> </ul> </div>

<divclass="Page-header"> class="badge">{{ques.creat_time}}</span></small>>class=" Lead">detail{{ques.detail}}</p> "{{url_for (' comment ')}}"Method="Post"style="..."> <divclass="Form-group"> <textarea name="new_comment"Id="new-comment" class="Form-control"Rows="3"placeholder="Write your comment"></textarea> <input type="Hidden"Name="question_id"Value="{{ques.id}}"> </div> <button type="Submit" class="btn Btn-default"> Send </button> </form> class="List-group"style="margin:10px"></ul>> <ulclass="List-group"style="...">       {% forFooinchQuestions%}           <liclass="List-group-item"> <spanclass="Glyphicon glyphicon-leaf"aria-hidden="true"></span> <a href="#">{{foo.author.username}}</a> <br> <a href="{{url_for (' detail ', Question_id=foo.id)}}">{{Foo.title}}</a> <spanclass="badge">{{foo.creat_time}}</span> <p style="...">{{Foo.detail}}</p> </li>       {% ENDFOR%}   </ul>

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.