本文整理汇总了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"
})
示例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,
}))