本文整理汇总了Python中models.Comment.article方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.article方法的具体用法?Python Comment.article怎么用?Python Comment.article使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.article方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: comment_add
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import article [as 别名]
def comment_add(request):
if request.method == 'POST':
article_id = request.POST.get('article_id','')
detail = request.POST.get('detail','')
#print 'okokokokokokokokoklalalallala'
if article_id and detail :
comment = Comment()
comment.detail = detail
comment.article = Article(aid=article_id)
comment.save()
return HttpResponseRedirect('/article/view/?aid=%s' % article_id)
示例2: postComment
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import article [as 别名]
def postComment(article_id):
article = Article.get_by_id(article_id)
if not article:
return "", 404, {"Content-Type": "application/json"}
data = request.get_json()
if not data:
return "Missing data", 400
comment = Comment()
comment.article = article.key
comment.author_name = escape(data.get("author_name"))
comment.author_email = escape(data.get("author_email"))
comment.content = escape(data.get("content"))
comment.put()
comments = Comment.query().order(Comment.date).fetch(keys_only=True)
if len(comments) >= 10:
comments[0].delete()
return serialize(comment)
示例3: add_comment
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import article [as 别名]
def add_comment(request,id):
info = ''
obj=get_object_or_404(Article,id=id)
name = request.POST.get('name','')
content = request.POST.get('comment','')
if not content:
info = u"评论为空"
else:
if not name and not request.user.is_authenticated():
name = u"匿名"
com = Comment(name=name,content=content)
com.article = obj
if request.user.is_authenticated():
com.created_by = request.user
com.save()
info = u"添加成功"
data = {'info':info}
return HttpResponse(LazyEncoder().encode(data), mimetype='application/json')