标签:循环 数据 enter orm http group hold 结果 评论列表
首页列表显示全部问答:
@app.route(‘/‘) def index(): context = { ‘questions‘: Question.query.order_by(‘creat_time‘).all() } return render_template("index.html", **context)
<ul class="list-group"style="width: 400px" align="center"> {% for foo in questions %} <li class="list-group-item"style="background-color:lightblue;height:190px;width:400px;"> <span class="glyphicon glyphicon-leaf" aria-hidden="true"></span> <a href="{{ url_for(‘detail‘ ,question_id=foo.id)}}">id:{{ foo.author.username }}</a> <br> <a href="http://www.jianshu.com/">标题:{{ foo.title }}</a> <br> <p style="color:black">详情:{{ foo.detail }}</p> <br> <span class="badge"style="margin-left: 50%">{{ foo.creat_time }}</span> </li> {% endfor %} </ul>
{% extends ‘index.html‘ %} {% block title %}问答详情{% endblock %} {% block main %} <div class="container"> <div class="box"> <h3 style="font-family:宋体;text-align: left;font-size: 40px">详情页</h3> </div> <h2>问题</h2> <h2>作者</h2> <p class="lead">detail:简书是一个优质的创作社区</p> <hr> <form action="{{ url_for(‘question‘) }}" method="post"> <div><textarea class="form-control" id="new_comment" rows="6" placeholder="write your comment"style="height:200px;width:800px" ></textarea><br></div> <button type="submit" class="fabu"style="width:100px">发布</button> </form> <ul class="list-group" style="margin: 10px"></ul> </div> {% endblock %}
标签:循环 数据 enter orm http group hold 结果 评论列表
原文地址:http://www.cnblogs.com/222ya/p/7988555.html