本文整理汇总了Python中model.Category.create方法的典型用法代码示例。如果您正苦于以下问题:Python Category.create方法的具体用法?Python Category.create怎么用?Python Category.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Category
的用法示例。
在下文中一共展示了Category.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: syncdb
# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import create [as 别名]
def syncdb():
from lib.util import find_subclasses
from model import db, User, Distribution, Category, Page
models = find_subclasses(db.Model)
for model in models:
if model.table_exists():
model.drop_table()
model.create_table()
logging.info('created table:%s' % model._meta.db_table)
User.create(mobile = 'root', password = User.create_password('111111'), group = 9)
Distribution.create(name = '免费配送', price = 0)
Distribution.create(name = '上门自提', price = 0)
Category.create(name = '积分商品', slug = 'credit', order = 1)
Category.create(name = '搭配购买', slug = 'acc', order = 2)
Category.create(name = '鸡', slug = 'ji', order = 3)
Category.create(name = '鸭', slug = 'ya', order = 4)
Category.create(name = '鹅', slug = 'e', order = 5)
Category.delete().where(Category.id == 1).execute()
Category.delete().where(Category.id == 2).execute()
#Category.create(name = '乳脂奶油蛋糕', slug = 'creambutter', order = 6)
#Category.create(name = '冰淇淋蛋糕', slug = 'icecream', order = 7)
Page.create(name = '菜市优品', slug = 'aboutus', content = '')
Page.create(name = '包装展示', slug = 'bzzs', content = '')
Page.create(name = '订购说明', slug = 'dgsm', content = '')
Page.create(name = '如何收货', slug = 'rhsh', content = '')
Page.create(name = '付款方式', slug = 'fkfs', content = '')
Page.create(name = '配送范围', slug = 'psfw', content = '')
logging.info('superuser - username:root password:111111')
示例2: syncdb
# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import create [as 别名]
def syncdb():
from lib.util import find_subclasses
from model import db, User, Distribution, Category, Page
#models = find_subclasses(db.Model)
#for model in models:
# if model.table_exists():
# model.drop_table()
# model.create_table()
# logging.info('created table:%s' % model._meta.db_table)
#User.create(mobile = 'root', password = User.create_password('111111'), group = 9)
Distribution.create(name = u'免费配送', price = 0)
Distribution.create(name = u'上门自提', price = 0)
Category.create(name = u'积分商品', slug = 'credit', order = 1)
Category.create(name = u'搭配购买', slug = 'acc', order = 2)
Category.create(name = u'慕斯蛋糕', slug = 'mousse', order = 3)
Category.create(name = u'巧克力蛋糕', slug = 'chocolate', order = 4)
Category.create(name = u'乳酪蛋糕', slug = 'cheese', order = 5)
Category.create(name = u'乳脂奶油蛋糕', slug = 'creambutter', order = 6)
Category.create(name = u'冰淇淋蛋糕', slug = 'icecream', order = 7)
Page.create(name = u'吉米的厨房', slug = 'aboutus', content = '')
Page.create(name = u'包装展示', slug = 'bzzs', content = '')
Page.create(name = u'订购说明', slug = 'dgsm', content = '')
Page.create(name = u'如何收货', slug = 'rhsh', content = '')
Page.create(name = u'付款方式', slug = 'fkfs', content = '')
Page.create(name = u'配送范围', slug = 'psfw', content = '')
logging.info('superuser - username:root password:111111')