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


    显示所有评论

    {% for foo in ques.comments %}

    所有评论排序

    uquestion = db.relationship('Question', backref=db.backref('comments', order_by=creat_time.desc))

    显示评论条数

    {{ ques.comments|length }}

    完成个人中心

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

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

    3.向前端页面传递参数

    4.页面显示相应数据

    发布的全部问答

    发布的全部评论

    个人信息

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

     <p>评论:({{ ques.comments|length }})</p>
                <table border=1 >
                    {% for foo in ques.comments %}
                        <tr><td>
                            <img class="people" src="{{ url_for('static',filename='image/people.png') }}">
                        <a href="{{ url_for('all',user_id=foo.author_id) }}" class="name">{{ foo.author.username }}</a>
                         <span class="time" >{{ foo.creat_time }}</span><br>
                        <p class="nr">{{ foo.detail }}</p></td></tr>
                    {% endfor %}
    {% block pandle %}
        <body bgcolor="antiquewhite"><link rel="stylesheet" type="text/css" href="../static/css/dd.css">
        <div class="d1"><h3>全部问答</h3>
        {% for foo in questions%}
            <img class="people" src="{{ url_for('static',filename='image/people.png') }}"><a href="{{ url_for('all',user_id=foo.author_id) }}" class="name">{{ foo.author.username }}<br></a>
            <table border="1" >
                    <tr><td>
                        <p>{{ foo.title }}</p>
                        <p>{{ foo.detail }}</p></td></tr>
            </table>
         {% endfor %}<hr>
    
        <h3>全部评论</h3>
        {% for foo in comments%}
            <img class="people" src="{{ url_for('static',filename='image/people.png') }}"><a href="{{ url_for('all',user_id=foo.author_id) }}" class="name">{{ foo.author.username }}</a>
            <table border="1" >
                    <tr><td><span class="time" >{{ foo.creat_time }}</span><br>
                    <p>{{ foo.detail }}</p></td></tr>
            </table>
         {% endfor %}<hr>
    {#        <img class="people" src="{{ url_for('static',filename='image/people.png') }}"><a href="{{ url_for('all',user_id=foo.author_id) }}" class="name">{{ foo.author.username }}</a><br>#}
           <h3>个人信息</h3>
            <table border="1" >
                <tr><td>
                <li style="list-style:none">用户:{{ username }}</li>
                <li style="list-style:none">ID号:{{ userid }}</li></td></tr>
    {#          <li>昵称</li>    #}
    {#          <li>文章篇数</li>  #}
            </table>
        </div>
        </body>
    {% endblock %}

     

  • 相关阅读:
    【bzoj3676】[Apio2014]回文串 —— 回文自动机的学习
    树链剖分求LCA
    读入输出优化
    【bzoj3124】[Sdoi2013]直径
    【codevs2183】匹配字符串
    【codevs2011】【LNOI2013】最小距离之和
    【codevs1306】广播操的游戏
    【hdu3966】Aragorn's Story
    【hdu3518】Boring counting
    C++-HDU3400-Line belt[三分]
  • 原文地址:https://www.cnblogs.com/1244581939cls/p/8033306.html
Copyright © 2020-2023  润新知