zoukankan      html  css  js  c++  java
  • 首页列表显示全部问答,完成问答详情页布局

    1. 首页列表显示全部问答:
      1. 将数据库查询结果传递到前端页面 Question.query.all()
      2. 前端页面循环显示整个列表。
      3. 问答排序
    2. 完成问答详情页布局:
      1. 包含问答的全部信息
      2. 评论区
      3. 以往评论列表显示区。
    3. 在首页点击问答标题,链接到相应详情页。
    @app.route('/detail/<post_id>')
    def detail(post_id):
    post=Post.query.filter(Post.id==post_id).first()
    return render_template('detail.html', post=post)
    @app.route('/')
    def jianshu():
        context={
            'post':Post.query.order_by('-creat_time').all()
        }
        return render_template('jianshu.html',**context)
    {% extends 'jianshu.html' %}
    {% block title %}问答详情{% endblock %}
    
    {% block main %}
       <div class="page-header">
       <h3>题目:{{ post.title }}
           <br><small>作者:{{ post.author_id }}发布时间:{{ post.creat_time }}
           </small></h3>
       </div>
        <p class="lead">详情:{{ post.detail }} </p>
        <br>
        <form action="{{ url_for('post') }}" method="post"></form>
        <div class="form-group">
            <textarea name="new_comment" id="new_comment"  rows="3" placeholder="请写下你的评论"></textarea>
        </div>
        <button type="submit" class="btn btn-default" onclick="">发送</button>
      </form>
        <ul class="list-group" style="margin: 10px"></ul>
    {% endblock %}
  • 相关阅读:
    【区间DP&&记忆化搜索】乘法游戏
    洛谷P1608路径统计
    2021省选游记
    涂色计划P4170
    01迷宫及路径记录(DFS&&BFS)
    [YBTOJ递推算法强化训练4]序列个数
    C++关于string 的优先队列以及重载运算符
    浅谈C++STL容器
    集合的划分
    图的表示
  • 原文地址:https://www.cnblogs.com/lintingting/p/7944282.html
Copyright © 2011-2022 走看看