日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

评论列表显示及排序,个人中心显示

發布時間:2025/7/25 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 评论列表显示及排序,个人中心显示 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • 顯示所有評論
    {% for foo in ques.comments %}

  • 所有評論排序
    uquestion = db.relationship('Question', backref=db.backref('comments', order_by=creat_time.desc))

  • 顯示評論條數
    {{ ques.comments|length }} <h4>評論:({{ ques.comments|length }})</h4><ul class="list-unstyled">{% for foo in ques.comments %}<li class="list-group-item"><a href="{{url_for('usercenter',user_id=foo.author.id)}}">{{foo.author.username }}</a><span class="badge pull-right">{{ foo.create_time }}</span><p>{{ foo.detail }}</p><br></li>{% endfor %}</ul>
  • 完成個人中心
  • 1.個人中心的頁面布局(html文件及相應的樣式文件)

    2.定義視圖函數def usercenter(user_id):

    3.向前端頁面傳遞參數

    4.頁面顯示相應數據

    發布的全部問答

    發布的全部評論

    個人信息

    5.各個頁面鏈接到個人中心 ? ? ?

    html

    {% extends 'base.html' %} {% block title %}個人中心 {% endblock%} {% block main%}<div class="page-header"><h3>{{username}} </h3><br>全部問答<span class="badge"></span><ul class="list-group" style="">{% for foo in user.question %}<li class="list-group-item"><a href="#">{{foo.author.username }}</a><span class="badge">{{foo.creat_time}}</span><p style="">{{foo.detail}}</p></li>{% endfor %}</ul> </div><div class="page-header"><h3><span class="glyphicon glyphicon-user" aria-hidden="true"></span>{{user}} <br> <small>個人信息><span class="badge"></span> </small></h3><ul class="list-group" style="">{% for foo in user.comments %}<li class="list-group-item"><span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span><a href="#">{{foo.author.username }}</a><span class="badge">{{foo.creat_time}}</span><p style="">{{foo.detail}}</p></li>{% endfor %}</ul> </div><div class="page-header"><h3><span class="glyphicon glyphicon-user" aria-hidden="true"></span>{{user}} <br> <small>個人信息><span class="badge"></span> </small></h3><ul class="list-group" style=""><li class="list-group-item">用戶:{{username}}</li><li class="list-group-item">編號:</li><li class="list-group-item">文章篇:</li></ul> </div>{% endblock %}

    py

    @app.route('/usercenter/<user_id>') @log def usercenter(user_id):user=User.query.filter(User.id==user_id).first()mycontext={'username':user.username,'questions':user.question,'comments':user.comments,}return render_template('usercenter.html',**mycontext)

    ?

    ?

    轉載于:https://www.cnblogs.com/00js/p/8034827.html

    總結

    以上是生活随笔為你收集整理的评论列表显示及排序,个人中心显示的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。