标签:数据库 href author inpu 信息 index row question 完成
首页列表显示全部问答:
@app.route(‘/‘) def index(): context={ "questions":Question.query.order_by(‘create_time‘).all() } return render_template(‘base.html‘,**context)
完成问答详情页布局:
{% block body %} <h1>提问详情</h1> <div class="container"> <div class="row clearfix"> <div class="col-md-12 column"> <h3 class="text-center"> title </h3> <p class="text-center"> detail </p> <form role="form"> <div class="form-group"> <label for="exampleInputAnswer">Write down your answer</label><input type="answer" class="form-control" id="exampleInputAnswer1" /> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </div> </div> {% endblock %}
{% block main %} <p>{{ username }} contextx</p> <ul class="new-list"> {% for foo in questions %} <li class="list-group" style="padding-left: 0px; padding-right: 10px; box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 0px 0px;"> <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span> <a href="#">{{ foo.author.username }}</a><br> <a href="{{ url_for(‘detail‘,questions_id=foo.id) }}">{{ foo.title }}</a>{#链接到相关详情页#} <span class="time" >{{ foo.create_time }}</span> <p>{{ foo.detail }}</p> </li> {% endfor %} </ul> {% endblock %}
标签:数据库 href author inpu 信息 index row question 完成
原文地址:http://www.cnblogs.com/wuyishan/p/7955361.html