本文整理汇总了Python中blog.models.Comment.thread方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.thread方法的具体用法?Python Comment.thread怎么用?Python Comment.thread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Comment
的用法示例。
在下文中一共展示了Comment.thread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: blog_show
# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import thread [as 别名]
def blog_show(request, id=''):
try:
blog = Blog.objects.get(id=id)
except Blog.DoesNotExist:
raise Http404
comment = blog.comment_set.all().order_by('thread')
blog.visitedTime=blog.visitedTime+1
blog.save()
tags = Tag.objects.all()
classification=Classification.objects.all()
blog_popular = Blog.objects.all().order_by('-visitedTime')[0:15]
if request.method =='POST':
form = cmtAddForm(request.POST)
if form.is_valid():
data = form.cleaned_data
cmt = Comment(username=data['name'],email=data['email'],content=data['content'],blog=blog)
father = data['thread']
print father;
if father:
father_cmt = Comment.objects.get(id=father)
father_cmt.sonCnt +=1
father_cmt.save()
cmt.thread =father_cmt.thread + '%4d'%father_cmt.sonCnt+'.'
else:
cmt.thread ='%4d'%(len(comment)+1)+'.'
cmt.save()
return HttpResponseRedirect('/blog/blog/%s/commentshow'%id)
else:
print "+++++++++++++++++hello+++++++++++++++"
raise Http404
else:
form = cmtAddForm()
return render_to_response("blog_show.html", {"blog": blog,"tags":tags,
"blog_popular":blog_popular,
"classification":classification,
"comment":comment,
"form":form,
"cmtlen":len(comment)},
context_instance=RequestContext(request))