本文整理汇总了Python中forum.models.Post.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Post.objects方法的具体用法?Python Post.objects怎么用?Python Post.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum.models.Post
的用法示例。
在下文中一共展示了Post.objects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showtopic
# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import objects [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),
)
示例2: grouptopics_reply
# 需要导入模块: from forum.models import Post [as 别名]
# 或者: from forum.models.Post import objects [as 别名]
def grouptopics_reply(self):#我回复的话题
from forum.models import Post
return Post.objects(author=self).distinct('topic')