本文整理匯總了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)