本文整理汇总了Python中models.Comment.user_id方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.user_id方法的具体用法?Python Comment.user_id怎么用?Python Comment.user_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.user_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tweet_comment
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user_id [as 别名]
def tweet_comment(tweet_id):
user = current_user()
if user is not None:
comment = Comment(request.form)
comment.tweet_id = tweet_id
comment.user_id = user.id
comment.save()
return redirect(url_for('tweet_comment_view', tweet_id=tweet_id))
else:
return redirect(url_for('login_view'))
示例2: attach_comment_to_project
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user_id [as 别名]
def attach_comment_to_project(id):
form = CommentForm()
if form.validate_on_submit():
comment = Comment()
comment.user_id = session['id']
comment.project_id = id
comment.comment = form.comment.data
db.session.add(comment)
db.session.commit()
return "success", 201
return render_template("create_comment.html", form=form, url = "/project/add/" + str(id) + "/comment")
示例3: post
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import user_id [as 别名]
def post(id):
post = Post.query.get_or_404(id)
form = forms.CommentForm()
if request.method=='POST':
comment = Comment()
comment.content = form.content.html
comment.user_id = current_user.id
comment.post_id = id
comment.time_stamp = datetime.now()
db.session.add(comment)
db.session.commit()
return redirect(url_for('.post',id=id,page=-1))
page = request.args.get('page',1,type=int)
if page==-1:
page = (post.comments.count() - 1) / COMMENTS_PER_PAGE + 1
comments = post.comments.order_by(Comment.time_stamp.asc()).paginate(page,COMMENTS_PER_PAGE,False)
Post.query.filter(Post.id==id).update({Post.view_times:Post.view_times+1})
return render_template('post.html',post=post,comments=comments,form=form)