- 主PY文件写视图函数,带id参数。
-
@app.route('/detail/<question_id>')
def detail(question_id):
quest =
return render_template('detail.html', ques = quest) - 首页标题的标签做带参数的链接。
- {{ url_for('detail',question_id = foo.id) }}
- 在详情页将数据的显示在恰当的位置。
-
{{ ques.title}}
{{ ques.id }}{{ ques.creat_time }}{{ ques.author.username }}
{{ ques.detail }}
1 @app.route('/detail/<question_id>') 2 def detail(question_id): 3 quest = Question.query.filter(Question.id == question_id).first() 4 return render_template('detail.html',ques = quest)1 <a href="{{ url_for('detail',question_id = foo.id) }}">{{ foo.title }}</a>