本文整理匯總了Python中comments.models.Comment.title方法的典型用法代碼示例。如果您正苦於以下問題:Python Comment.title方法的具體用法?Python Comment.title怎麽用?Python Comment.title使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類comments.models.Comment
的用法示例。
在下文中一共展示了Comment.title方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: new_comment
# 需要導入模塊: from comments.models import Comment [as 別名]
# 或者: from comments.models.Comment import title [as 別名]
def new_comment(request):
# saving the poted comment
if request.method == 'POST':
form = CommentForm(request.POST)
if form.is_valid():
comment = Comment()
comment.book = form.cleaned_data.get("book")
comment.chapter = form.cleaned_data.get("chapter")
comment.example = form.cleaned_data.get("example")
comment.page = form.cleaned_data.get("page")
comment.title = form.cleaned_data.get("title")
comment.body = form.cleaned_data.get("body")
comment.email = form.cleaned_data.get("email", "Anonymous")
comment.save()
return HttpResponseRedirect(
'/comments/get/?book={0}&chapter={1}&example={2}&page={3}'.format(
comment.book, comment.chapter, comment.example, comment.page
)
)
else:
book = request.POST.get('book', '')
chapter = request.POST.get('chapter', '')
example = request.POST.get('example', '')
page = request.POST.get('page', '')
return HttpResponseRedirect(
'/comments/new/?book={0}&chapter={1}&example={2}&page={3}'.format(
book, chapter, example, page
)
)
# retriving comment parameters
book = request.GET.get('book', '')
chapter = request.GET.get('chapter', '')
example = request.GET.get('example', '')
page = request.GET.get('page', '')
initial_values = {
'book': book,
'chapter': chapter,
'example': example,
'page': page
}
form = CommentForm(initial = initial_values)
context = {
'form': form,
'book': book,
'chapter': chapter,
'example': example,
'page': page
}
context.update(csrf(request))
return render(request, 'comments/new_comment.html', context)