本文整理汇总了Python中comments.models.Comment.created方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.created方法的具体用法?Python Comment.created怎么用?Python Comment.created使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comments.models.Comment
的用法示例。
在下文中一共展示了Comment.created方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_comments
# 需要导入模块: from comments.models import Comment [as 别名]
# 或者: from comments.models.Comment import created [as 别名]
def migrate_comments(self):
for legacy_comment in LegacyComment.objects.all():
assert isinstance(legacy_comment, LegacyComment)
date_naive = datetime.utcfromtimestamp(legacy_comment.timestamp)
date = timezone.make_aware(date_naive, timezone.utc)
comment = Comment()
comment.body = legacy_comment.comment
comment.created = date
comment.public = not legacy_comment.officer
comment.user_id = legacy_comment.poster_id # this is erroring
if legacy_comment.section == 0:
continue
if legacy_comment.section == 1:
continue
if legacy_comment.section == 2:
continue
if legacy_comment.section == 5:
continue
comment.content_type_id = { # i dont know what the keys are for the different content types
0: 1, # user manager
1: 2, # application
2: 3, # fodder vote
3: 4, # quote
4: 5, # screenshot
5: 6 # leadership application
}.get(legacy_comment.section)
comment.object_id = legacy_comment.reference
comment.save()