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

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

首页HTML

{% extends 'base.html' %}
{% block title %}首页{% endblock %}
{% block head %}
    {#    <script src="{{ url_for('static',filename='js/base.js') }}" type="text/javascript"></script>#}
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/index.css') }}">
{% endblock %}
{% block main %}
    <div class="content">
        <div class="img">
            <img src="{{ url_for('static',filename='images/cake1.jpg') }}"></a>
            <div class="desc"><a href="http://www.lecake.com/shop/goods-105601.html">天秤花园蛋糕 </a></div>
        </div>
        <div class="img">
            <img src="{{ url_for('static',filename='images/cake2.jpg') }}"></a>
            <div class="desc"><a href="http://www.lecake.com/shop/goods-105595.html">实栗派核桃栗蓉蛋糕 </a></div>
        </div>
        <div class="img">
            <img src="{{ url_for('static',filename='images/cake3.jpg') }}"></a>
            <div class="desc"><a href="http://www.lecake.com/shop/goods-105652.html">魔法引力蛋糕</a></div>
        </div>
        <div class="img">
            <img src="{{ url_for('static',filename='images/cake4.jpg') }}"></a>
            <div class="desc"><a href="http://www.lecake.com/shop/goods-100801.html">雪域牛乳芝士蛋糕</a></div>
        </div>
    </div>

    {#    <p>{{ user }}context</p>#}
    <div class="juli">
        {#<ul>
        <a class="author">{{ author}}</a>
        <a class="create_time">{{ create_time }}</a><br>
        <h3 class="title">{{ title}}</h3>
        <a class="detail">{{ detail}}</a>
    </ul>#}
    <ul>
        {% for foo in questions %}
            <li>
                <img id="tubiao" src="{{ url_for('static',filename='images/pl.jpg') }}">
                <a href="#">{{ foo.author.Username }}</a>
                <a class="creat_time" href="#">{{ foo.creat_time }}</a>
                <p class="title" href="#" onclick="window.location.replace({{ url_for('detailpage')}})">{{ foo.title }}</p>
{#                <p class="title" href="{{ url_for('detailpage')}}">{{ foo.title }}</p>#}
                <p class="abstract">{{ foo.detail }}</p>
            </li>
        {% endfor %}</ul>
    </div>
     {% endblock %}
{% extends 'base.html' %}
{% block title %}详情页{% endblock %}
{% block head %}
    {#    <script src="{{ url_for('static',filename='js/base.js') }}" type="text/javascript"></script>#}
    <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/detailpage.css') }}">
{% endblock %}
{% block main %}
    <div align="center">
        <div class="xianshi">
                    <h2>如何卓有成效地过一天</h2>
                    <p>yangmi</p>
                    <p>2017-12-5</p>
                   <p>detail</p>
            <br></div>
        <div class="ping">
            <div class="pinglun"><label for="comment">评论</label><br></div>
            <textarea id="comment" rows="12" name="commentdetail"></textarea></div>
        <input type="submit" class="fasong" value="发送评论">
    </div>
{% endblock %}

主页显示问答:

 

posted @ 2017-12-05 20:52  爱学习的土豆  阅读(145)  评论(0编辑  收藏  举报