本文整理匯總了Python中forum.models.Post.floor方法的典型用法代碼示例。如果您正苦於以下問題:Python Post.floor方法的具體用法?Python Post.floor怎麽用?Python Post.floor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類forum.models.Post
的用法示例。
在下文中一共展示了Post.floor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: showtopic
# 需要導入模塊: from forum.models import Post [as 別名]
# 或者: from forum.models.Post import floor [as 別名]
def showtopic(request, gurl_number, turl_number):
group = Group.objects(url_number=gurl_number).get()
topic = Topic.objects(url_number=turl_number).get()
topic.clicks += 1
topic.save()
if request.method == "POST":
form = NewPostForm(request.POST)
if form.is_valid():
content = form.cleaned_data["content"]
post = Post(content=content)
post.author = request.user
post.creat_time = datetime.datetime.now()
post.floor = Post.objects(topic=topic).count() + 1
post.topic = topic
post.is_active = True
post.save()
topic.update_author = request.user
topic.update_time = datetime.datetime.now()
topic.save()
return HttpResponseRedirect("/group/" + str(gurl_number) + "/topic/" + str(turl_number) + "/")
else:
form = NewPostForm()
return render_to_response(
"group/group_topic.html",
{"group": group, "current_user": request.user, "form": form, "topic": topic, "STATIC_URL": STATIC_URL},
context_instance=RequestContext(request),
)