本文整理汇总了Python中models.category.Category.create方法的典型用法代码示例。如果您正苦于以下问题:Python Category.create方法的具体用法?Python Category.create怎么用?Python Category.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.category.Category
的用法示例。
在下文中一共展示了Category.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modify_blog
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import create [as 别名]
def modify_blog(cls, blog_id, title, tag, category, hide, content):
blog = cls.get(cls.id == blog_id)
blog.title = title
if hide == 'False':
blog.hide = False
else:
blog.hide = True
blog.content_md = content
blog.content_html = md2html(content)
blog.save()
check_tag = Tags.has_tag(tag)
blogtags = BlogTags.get(BlogTags.blog_id == blog.id)
if check_tag:
blogtags.tags_id = check_tag.id
else:
tag = Tags.create(tag=tag)
blogtags.tags_id = tag.id
blogtags.save()
check_category = Category.has_category(category)
blogcategory = BlogCategory.get(BlogCategory.blog_id == blog.id)
if check_category:
blogcategory.category_id = check_category.id
else:
category = Category.create(category=category)
blogcategory.category_id = category.id
blogcategory.save()
示例2: category_create
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import create [as 别名]
def category_create():
try:
name = request.form['name']
except KeyError:
return error(400, u'参数错误')
category = Category.create(**locals())
if not category:
return error(100021, 'create category failed')
return category
示例3: create_new_blog
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import create [as 别名]
def create_new_blog(cls, title, tag, category, hide, content):
blog = cls.create(title=title,
content_md=content)
if hide == 'False':
blog.hide = False
else:
blog.hide = True
blog.content_html = md2html(content)
blog.save()
check_tag = Tags.has_tag(tag)
if check_tag:
BlogTags.create(blog_id=blog.id, tags_id=check_tag.id)
else:
tag = Tags.create(tag=tag)
BlogTags.create(blog_id=blog.id, tags_id=tag.id)
check_category = Category.has_category(category)
if check_category:
BlogCategory.create(blog_id=blog.id, category_id=check_category.id)
else:
category = Category.create(category=category)
BlogCategory.create(blog_id=blog.id, category_id=category.id)