首頁列表顯示所有問答,完成問答詳情頁佈局。

  1. 首頁列表顯示所有問答:
    1. 將數據庫查詢結果傳遞到前端頁面 Question.query.all()
    2. 前端頁面循環顯示整個列表。
    3. 問答排序
  2. 完成問答詳情頁佈局:
    1. 包含問答的所有信息
    2. 評論區
    3. 以往評論列表顯示區。
  3. 在首頁點擊問答標題,連接到相應詳情頁。
@app.route('/')
def base():
    context = {
        'questions': Question.query.all()
    }
    return render_template("base.html",**context)

    {% for foo in questions %}
        <ul class="list-group">
    <li class="list-group-item">
        <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span>
        <a href="detail.html">{{foo.author.username}}</a>
        <br>
        <a href="#">{{ foo.title }}</a><br>
        <span class="badge">{{ foo.creat_time }}</span><br>
        <p style="color:black">{{ foo.detail}}</p><br>
    </li>


{% endfor %}
</ul> </div>
</head>
<body id="body">

<div class="essayAera">

                        <ul class="list-group">
                            <li><a  class="author" href="">做者名</a></li>
                            <br>
                       <li> <a class="title"  href="">標題名</a></li>
                                <br>
                              <li>  <span >建立時間</span></li>
                        <li><p class="abstract">內容明細</p></li>

                        <form action="">
                        <div class="form-group">
                        <textarea class="inputFramework"cols="50" rows="6" id="details" name="detail"></textarea>

                        </div>
                            <button type="submit" class="btn btn-default">發送</button>
                                </form>

                        </ul>
</div>
</body>
</html>

相關文章
相關標籤/搜索