当前位置: 首页>>代码示例>>Python>>正文


Python Comment.paper方法代码示例

本文整理汇总了Python中models.Comment.paper方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.paper方法的具体用法?Python Comment.paper怎么用?Python Comment.paper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Comment的用法示例。


在下文中一共展示了Comment.paper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: submit_comment_view

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import paper [as 别名]
def submit_comment_view(request):
    import forms
    user = UserProfile.objects.get(username=request.user.username)

    try:
        if request.method == 'GET':
            paper_id = int(request.GET['id'])
        elif request.method == 'POST':
            paper_id = int(request.POST['id'])
        paper = Paper.objects.filter(id=paper_id).get()
        comment = Comment()
        comment.paper = paper
        comment.user = user
        if request.method == 'POST':
            form = forms.SubmitCommentForm(request.POST, instance=comment)
            if form.is_valid():
                form.save(paper)
                return HttpResponseRedirect("paper?id=%s" % paper_id)
        else:
            form = forms.SubmitCommentForm()
    except (ValueError, KeyError, Paper.DoesNotExist):
        paper = None
        form = None

    return render(request, "submit_comment.html", {
        'form' : form,
        'paper' : paper,
        'which_page' : "submit_comment"
    })
开发者ID:jeanqasaur,项目名称:jeeves,代码行数:31,代码来源:views.py

示例2: submit_comment_view

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import paper [as 别名]
def submit_comment_view(request):
    try:
        if request.method == 'GET':
            paper_id = int(request.GET['id'])
        elif request.method == 'POST':
            paper_id = int(request.POST['id'])
        paper = Paper.objects.filter(id=paper_id).get()
        comment = Comment()
        comment.paper = paper
        comment.user = request.user
        if request.method == 'POST':
            form = forms.SubmitCommentForm(request.POST, instance=comment)
            if form.is_valid():
                form.save(paper)
                return HttpResponseRedirect("paper?id=%d" % paper_id)
        else:
            form = forms.SubmitCommentForm()
    except (ValueError, KeyError, Paper.DoesNotExist):
        paper = None
        form = None

    return render_to_response("submit_comment.html", RequestContext(request, {
        'form' : form,
        'paper' : paper,
    }))
开发者ID:labdalla,项目名称:jeeves,代码行数:27,代码来源:views.py


注:本文中的models.Comment.paper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。