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


  1. 显示所有评论
    {% for foo in ques.comments %}
      {% for each in comments %}
                                <li class="list-group-item" >
                                <a  class="author" href="">{{ each.author.username }}</a>
                                <br>
                                    <br>
                                    <span >{{ each.create_time }}</span>
                            <p class="abstract">{{ each.detail }}</p>
                                </li>
                                {% endfor %}
    
  2. 所有评论排序
    uquestion = db.relationship('Question', backref=db.backref('comments', order_by=creat_time.desc))
    question = db.relationship('Question', backref=db.backref('comment', order_by=create_time.desc()))
    
  3. 显示评论条数
    {{ ques.comments|length }}
    <h4>评论:({{ ques.comment|length }})</h4>
    
  4. 完成个人中心

1.个人中心的页面布局(html文件及相应的样式文件)

2.定义视图函数def usercenter(user_id):

3.向前端页面传递参数

4.页面显示相应数据

发布的全部问答

发布的全部评论

个人信息

@app.route('/userCenter/<user_id>', methods=['GET'])
def userCenter(user_id):
    user = User.query.filter(User.id == user_id).first()
    context = {
        'username': user.username,
        'questions': user.question,
        'comments': user.comment
    }
    return render_template('userCenter.html', **context)

  

5.各个页面链接到个人中心

href="{{ url_for ('userCenter',user_id=each.author.id) }}"

每个页面用这句代码做相应修改即可

优质内容筛选与推荐>>
1、Decal Texture
2、本地编辑组策略
3、【JS】键盘鼠标事件
4、Spark RDD
5、修改时弹出的界面下拉列表显示信息与之前的信息保持一致


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn