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


Python Post.author方法代碼示例

本文整理匯總了Python中forum.models.Post.author方法的典型用法代碼示例。如果您正苦於以下問題:Python Post.author方法的具體用法?Python Post.author怎麽用?Python Post.author使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在forum.models.Post的用法示例。


在下文中一共展示了Post.author方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: showtopic

# 需要導入模塊: from forum.models import Post [as 別名]
# 或者: from forum.models.Post import author [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),
        )
開發者ID:pgwt,項目名稱:COC,代碼行數:30,代碼來源:views.py

示例2: mkpost

# 需要導入模塊: from forum.models import Post [as 別名]
# 或者: from forum.models.Post import author [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


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