作业32-完成评论功能
生活随笔
收集整理的這篇文章主要介紹了
作业32-完成评论功能
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
@app.route('/comment/',methods=['POST'])
def comment():
讀取前端頁(yè)面數(shù)據(jù),保存到數(shù)據(jù)庫(kù)中
?
?
?
?
1.顯示評(píng)論次數(shù)
<h4>評(píng)論:({{ ques.comments|length }}) </h4>?1.要求評(píng)論前登錄
@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().idcomm = 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))?
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/hegui/p/8003990.html
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專(zhuān)家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的作业32-完成评论功能的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。