本文整理汇总了Python中blog.models.Blog.name方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.name方法的具体用法?Python Blog.name怎么用?Python Blog.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Blog
的用法示例。
在下文中一共展示了Blog.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_sample
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import name [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,
)
示例2: post
# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import name [as 别名]
def post(self):
self._form = AddBlogForm(request.form)
if self._form.validate():
from blog.models import Blog
blog = Blog()
blog.name = self._form.name.data
blog.date_added = self._form.date_added.data
blog.title = self._form.title.data
blog.slug = self._form.slug.data
author_id = self._form.author_id.data
category = self._form.category.data
blog.save()
return self.redirect('blog.list')