當前位置: 首頁>>代碼示例>>Python>>正文


Python Post.thread方法代碼示例

本文整理匯總了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
開發者ID:FashtimeDotCom,項目名稱:pony-forum,代碼行數:16,代碼來源:model_tests.py

示例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)
    )
開發者ID:menglewis,項目名稱:djangoforum,代碼行數:24,代碼來源:views.py


注:本文中的forum.models.Post.thread方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。