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)
      

        

  • 相关阅读:
    up6-chrome 45+安装教程
    HttpUploader7-授权码配置
    jsp-MySQL连接池
    WordPaster2-正式包布署说明
    HTTP文件上传插件开发文档-ASP
    HTTP文件上传插件开发文档-JSP
    eWebEditor9.x整合教程-Xproer.WordPaster
    42. Trapping Rain Water
    41. First Missing Positive
    40. Combination Sum II
  • 原文地址:https://www.cnblogs.com/lhw1997/p/7994868.html
Copyright © 2011-2022 走看看