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

    1. 首页列表显示全部问答:
      1. 将数据库查询结果传递到前端页面 Question.query.all()
      2. 前端页面循环显示整个列表。
      3. 问答排序
    2. 完成问答详情页布局:
      1. 包含问答的全部信息
      2. 评论区
      3. 以往评论列表显示区。
    3. 在首页点击问答标题,链接到相应详情页。
      {% extends 'base.html' %}
      {% block title %}
      首页
      {% endblock %}
      {% block head %}
         <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/index.css') }}">
      
      {#    <p>{{ user }}context</p>#}
      {% endblock %}
      
      {% block main %}
        <img width="150" height="100" class="pfs" src="https://img3.doubanio.com/lpic/s7625404.jpg" alt="">
        <ul class="list-group">
              {% for foo in wd %}
                  <li class="list-group-item">
                      <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span>
                      <a href="{{ url_for('detail',question_id = foo.id)}}">{{foo.title}}</a>
                      <p style="">{{foo.detail}}</p>
                       <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
                      <a href="{{url_for('userconter',user_id = foo.author_id)}}">{{foo.author.username}}评论:({{foo.comments length}})</a>
                      <span class="badge">{{foo.creat_time}}</span>
      
                  </li>
      
        </ul>
      
      
      {% endblock %}
      

        

      @app.route('/')
      def base():
          context={
              'questions': Question.query.all()
          }
          return render_template('home.html',**context)
      

        

  • 相关阅读:
    ios添加pre和post build action
    Highcharts将数据以图表的形式展现
    【deep learning学习笔记】注释yusugomori的LR代码 --- 模型测试
    九乘九口诀算法
    JMS学习的个人理解笔记
    php与文件操作
    java 泛型
    约定
    写给自己,毕业三年,薪水涨了12倍,你信吗
    好技术领导和差技术领导区别在哪里--转
  • 原文地址:https://www.cnblogs.com/lhw1997/p/7994868.html
Copyright © 2011-2022 走看看