評論列表顯示及排序,我的中心顯示

  1. 顯示全部評論
    {% for foo in ques.comments %}

  2. 全部評論排序
    uquestion = db.relationship('Question', backref=db.backref('comments', order_by=creat_time.desc))

  3. 顯示評論條數
    {{ ques.comments|length }}
     <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 %}
  4. 完成我的中心

1.我的中心的頁面佈局(html文件及相應的樣式文件)css

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

3.向前端頁面傳遞參數前端

4.頁面顯示相應數據函數

發佈的所有問答佈局

發佈的所有評論url

我的信息spa

5.各個頁面連接到我的中心code

{% block jiemian %}
    <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 %}
 <a href="{{ url_for('all',user_id=foo.author_id) }}" class="name">{{ foo.author.username }}</a>

   

相關文章
相關標籤/搜索