本文整理汇总了Python中blog.models.Comment.content_raw方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.content_raw方法的具体用法?Python Comment.content_raw怎么用?Python Comment.content_raw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Comment
的用法示例。
在下文中一共展示了Comment.content_raw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: comment_create
# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import content_raw [as 别名]
def comment_create(request, post_slug):
try:
post = Post.objects.get(slug=post_slug)
except Post.DoesNotExist:
raise Http404()
if "content_raw" not in request.POST:
return redirect(
reverse("blog:post_detail", args=[post.category.name, post_slug]))
if not post.published and not request.user.is_superuser:
raise PermissionDenied()
comment = Comment()
if request.user.is_authenticated():
comment.user = request.user
else:
if ('user_name' not in request.POST or
'user_email' not in request.POST):
return redirect(
reverse(
"blog:post_detail", args=[post.category.name, post_slug]))
comment.user_name = request.POST['user_name']
comment.user_email = request.POST['user_email']
comment.content_raw = request.POST['content_raw']
comment.post = post
comment.save()
send_email_notification.delay(
title=u'Новый коментарии',
message=u'Новый коменатрии \n{0}\n{1}'.format(
reverse('blog:post_detail', args=[post.category.name, post_slug]),
datetime.datetime.now()))
return redirect(
reverse("blog:post_detail", args=[post.category.name, post_slug]))