本文整理匯總了Python中forum.models.Post.thread方法的典型用法代碼示例。如果您正苦於以下問題:Python Post.thread方法的具體用法?Python Post.thread怎麽用?Python Post.thread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類forum.models.Post
的用法示例。
在下文中一共展示了Post.thread方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: mkpost
# 需要導入模塊: from forum.models import Post [as 別名]
# 或者: from forum.models.Post import thread [as 別名]
def mkpost(content="Test post.",
creation_date=datetime.datetime.now()):
"""Helper function for making posts."""
p = Post()
# _plain == _html, since the conversion happens in views.py,
# which the object creation is not run through
p.content_plain, p.content_html = content, content
p.creation_date = creation_date
p.author = mkuser()
p.thread = mkthread()
p.save()
return p
示例2: reply
# 需要導入模塊: from forum.models import Post [as 別名]
# 或者: from forum.models.Post import thread [as 別名]
def reply(request, pk):
"View that handles POST request for a reply or renders the form for a reply"
error = ""
if request.method == "POST":
p = request.POST
if p["body_markdown"]:
thread = Thread.objects.get(pk=pk)
post = Post()
form = PostForm(p, instance=post)
post = form.save(commit=False)
post.thread, post.creator = thread, request.user
post.save()
return HttpResponseRedirect(reverse("forum.views.thread", args=[pk]) + "?page=last")
else:
error = "Please enter a Reply\n"
thread = Thread.objects.get(pk=pk)
post_form = PostForm()
return render_to_response(
"forum/reply.html", add_csrf(request, thread=thread, post_form=post_form, error=error, pk=pk)
)