标签:列表 功能 query span 方法 ret 定义 detail div
@app.route(‘/comment/‘,methods=[‘POST‘]) def comment(): comment = request.form.get(‘new-comment‘) ques_id = request.form.get(‘question_id‘) auth_id = User.query.filter(User.username == session.get(‘user‘)).first().id comm = Comment(author_id = auth_id, question_id=ques_id ,detail=comment) db.session.add(comm) db.session.commit() return redirect(url_for(‘detail‘))
<input type="hidden" name="question_id" value="{{ques.id}}" />
<h4>评论:({{ ques.comments|length }}) </h4>
@app.route(‘/comment/‘,methods=[‘POST‘]) @loginFrist def comment(): comment = request.form.get(‘new-comment‘) ques_id = request.form.get(‘question_id‘) auth_id = User.query.filter(User.username == session.get(‘user‘)).first().id comm = Comment(author_id = auth_id, question_id=ques_id ,detail=comment) db.session.add(comm) db.session.commit() return redirect(url_for(‘detail‘,question_id=ques_id))
<ul class="list-unstyled"> {% for foo in comments %} <li class="list-group-item"> <a>{{ foo.author.username }}</a> <span class="badge pull-right">{{ foo.creat_time }}</span> <p>{{ foo.detail }}</p> <br> </li> {% endfor %} </ul>
标签:列表 功能 query span 方法 ret 定义 detail div
原文地址:http://www.cnblogs.com/xyjie/p/8007128.html