本文整理汇总了Python中blog.models.Blog.submitter方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.submitter方法的具体用法?Python Blog.submitter怎么用?Python Blog.submitter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Blog
的用法示例。
在下文中一共展示了Blog.submitter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_sample
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import submitter [as 别名]
def create_sample(num_blogs=50,
num_posts_per_blog=4,
num_comments_per_post=7,
):
for name in names:
User.objects.create_user(name, '%[email protected]' % name, '')
users = list(User.objects.all())
for i in range(0, num_blogs):
blog = Blog()
blog.submitter = random.choice(users)
blog.name = random.choice(text.split())
blog.save()
for blog in Blog.objects.all():
blog.submitter = random.choice(users)
blog.save()
for i in range(0, num_posts_per_blog):
post = Post.objects.create(body=text,
blog=blog,
name=random.choice(text.split()),
)
for u in users:
if random.choice(range(0, 6)) == 0:
post.likers.add(u)
for post in Post.objects.all():
for i in range(0, num_comments_per_post):
PostComment.objects.create(submitter=random.choice(users),
post=post,
body=text,
)