本文整理匯總了Python中comments.models.Comment.post方法的典型用法代碼示例。如果您正苦於以下問題:Python Comment.post方法的具體用法?Python Comment.post怎麽用?Python Comment.post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類comments.models.Comment
的用法示例。
在下文中一共展示了Comment.post方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create
# 需要導入模塊: from comments.models import Comment [as 別名]
# 或者: from comments.models.Comment import post [as 別名]
def create(self, validated_data):
"""
Create and return a new 'Comment' instance, given the validated data
This is like the form class's save method.
Serializers have a save method, which will in turn invoke these
functions
"""
print "CommentSerializer: In Create"
comment = Comment()
comment.author = validated_data.get('author', None)
if comment.author is None:
comment.author_name = validated_data.get('author_name', None)
comment.author_email = validated_data.get('author_email', None)
comment.author_url = validated_data.get('author_url', None)
if comment.author_name is None and comment.author_email is None:
return None
comment.body = validated_data.get('body')
comment.post = validated_data.get('post')
comment.published = False
if comment.author is not None and settings.COMMENT_MODERATION_ENABLED is not True:
comment.published = True
elif comment.author is not None and comment.author.is_staff:
comment.published = True
comment.save()
return comment