本文整理汇总了Python中blog.models.Comment.associated_with方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.associated_with方法的具体用法?Python Comment.associated_with怎么用?Python Comment.associated_with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Comment
的用法示例。
在下文中一共展示了Comment.associated_with方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: entry
# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import associated_with [as 别名]
def entry(request, blog_slug):
"""
Defines the page of a single blog entry.
Finds the entry based on its slugified title, passed in by blog_slug.
"""
the_entry = get_object_or_404(Entry, slug=blog_slug)
tags = Tag.objects_by_entry_count.all()
comment_form = CommentForm()
if request.method == "POST":
new_comment = Comment()
new_comment.content = request.POST["content"]
new_comment.author = request.user
new_comment.published = datetime.now()
new_comment.associated_with = the_entry
new_comment.save()
return render(request, "individual_blog.html", {
"entry": the_entry,
"comment_form": comment_form,
"tags": tags
})