本文整理汇总了Python中models.users.Users.get_or_create方法的典型用法代码示例。如果您正苦于以下问题:Python Users.get_or_create方法的具体用法?Python Users.get_or_create怎么用?Python Users.get_or_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.users.Users
的用法示例。
在下文中一共展示了Users.get_or_create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get_or_create [as 别名]
def __init__(self):
db.connect()
if not Version.table_exists():
tablesName = [
Version,
Albums,
Chatrooms,
Categories,
ProductComments,
ProductFavorites,
ProductRankings,
ProductPayments,
Products,
GroupComments,
GroupFavorites,
GroupRankings,
GroupPayments,
Groups,
Images,
Roles,
Transactions,
Users,
Articles,
Answners,
Questions,
]
for i in tablesName:
i.create_table()
self.version=Version.get_or_create(description=open('VERSION').read())
self.admin_role = Roles.get_or_create(type=1, description='系统管理员')
self.assistant_role = Roles.get_or_create(type=10, description='班级管理员')
self.student_role = Roles.get_or_create(type=100, description='注册学员')
self.default_thumbnail = base64.b64encode(buffer(imaging.default_thumbnail()))
self.sys_categories = Categories.get_or_create(
name = '系统预置分类',
description = '预置的初始父类!',
thumbnail = self.default_thumbnail,
)
self.admin = Users.get_or_create(
name = 'admin',
cellphone = '13912345678',
email = '[email protected]',
password = '21232f297a57a5a743894a0e4a801fc3',
gender = 0,
role = self.admin_role,
description = '预置的系统管理员!',
avatur = self.default_thumbnail
)
self.sys_album = Albums.get_or_create(
name = '系统专辑',
description = '预置的系统专辑!',
thumbnail = self.default_thumbnail,
owner = self.admin
)
self.sys_image = Images.get_or_create(
description = '预置的系统图片!',
thumbnail = self.default_thumbnail,
owner = self.admin,
album = self.sys_album,
uuid = 'default'
)