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

  1. 首页列表显示全部问答:
    1. 将数据库查询结果传递到前端页面 Question.query.all()
    2. 前端页面循环显示整个列表。
    3. 问答排序
  2. 完成问答详情页布局:
    1. 包含问答的全部信息
    2. 评论区
    3. 以往评论列表显示区。
  3. 在首页点击问答标题,链接到相应详情页。
    @app.route('/')
    def shouye():
        context={
            'questions':Question.query.all()
        }
        return render_template('shouye.html',**context)
    @app.route('/xiangqing/')
    def xiangqing():
        return render_template('xiangqing.html')
    {% block jiemian %}
        <link rel="stylesheet" type="text/css" href="../static/css/pl.css">
              {% for foo in questions %}
                  <ul class="zongl" >
                  <li>{{ foo.author.username }}</li>
                      <a href="{{ url_for("xiangqing") }}">标题:{{ foo.title }}</a>
                      <li>详情:{{ foo.detail }}</li>
                      <li>发布时间:{{ foo.creat_time }}</li>
                      <br>
                  </ul>
              {% endfor %}
    {% endblock %}
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link rel="stylesheet" type="text/css" href="../static/css/cc.css">
    </head>
    
    <body bgcolor="antiquewhite">
        <div class="d1">
            <h>标题</h><br>
            <li>username</li>
            <li>creatTime</li>
            <hr>
            <li>标题</li>
            <hr>
            <textarea name='pinglun'></textarea>
            <br><button>发布</button>
            <p>评论:(#)</p>
    
            <table border=2 >
                <tr><td>评论详情</td></tr>
                <tr><td>评论详情</td> </tr>
                <tr><td>评论详情</td></tr>
                </tr>
            </table>
    </div>
    </body>
    </html>

     

     

posted on 2017-12-05 22:59  079刘洁婷  阅读(111)  评论(0编辑  收藏  举报

导航