首页列表显示全部问答,完成问答详情页布局。

  1. 首页列表显示全部问答:
    1. 将数据库查询结果传递到前端页面 Question.query.all()
    2. 前端页面循环显示整个列表。
    3. 问答排序
  2. 完成问答详情页布局:
    1. 包含问答的全部信息
    2. 评论区
    3. 以往评论列表显示区。
  3. 在首页点击问答标题,链接到相应详情页
    @app.route('/')
    def index():
        context = {
            'question':Question.query.all()
        }

     

    {% extends 'base.html' %}
    
    {% block title %}Detail{% endblock %}
    
    {% block head %}
        <link href="{{ url_for('static',filename='CSS/detail.css') }}" rel="stylesheet" type="text/css">
    {% endblock %}
    
    {% block main %}
    <div class="detail">
        <h2>title</h2>
        <a href="#">username</a>
        <span>creat_time</span>
        <div class="p">
            <p>detail</p>
        </div>
        <textarea rows="5"></textarea><br>
        <button >发送</button>
        <br>
        <ul>
            <p>Comment</p>
            <li>
                <a href="#">username</a>
                <span>creat_time</span><br>
                <p>comment</p>
            </li>
            <li>
                <a href="#">username</a>
                <span>creat_time</span><br>
                <p>comment</p>
            </li>
        </ul>
    </div>
    {% endblock %}
    @app.route('/detail/')
    def detail():
        return render_template('detail.html')

posted @ 2017-12-06 10:39  060王昊  阅读(115)  评论(0编辑  收藏  举报