本文整理汇总了Python中blog.models.BlogPost.content方法的典型用法代码示例。如果您正苦于以下问题:Python BlogPost.content方法的具体用法?Python BlogPost.content怎么用?Python BlogPost.content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.BlogPost
的用法示例。
在下文中一共展示了BlogPost.content方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_blog_post
# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import content [as 别名]
def generate_blog_post():
post = BlogPost()
post.name = random.choice(long_actions)
post.content = user_description
post.date = generate_datetime()
post.published = True
post.save()
示例2: update_blog_post
# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import content [as 别名]
def update_blog_post(title, content, is_published, blog_post_id=None):
if not blog_post_id:
p = BlogPost()
else:
p = get_blog_post(blog_post_id)
p.title = title
p.content = content
p.is_published = bool(is_published)
p.put()
return p
示例3: test_create_post
# 需要导入模块: from blog.models import BlogPost [as 别名]
# 或者: from blog.models.BlogPost import content [as 别名]
def test_create_post(self):
user = User.objects.get(username='AAA')
post = BlogPost(user=user)
post.title = "My test post"
post.content = "This is a test post"
post.save()
all_posts = BlogPost.objects.all()
self.assertEquals(len(all_posts), 1)
only_post = all_posts[0]
self.assertEquals(only_post, post)
self.assertEquals(only_post.title, "My test post")