本文整理汇总了Python中accounts.models.User.organization方法的典型用法代码示例。如果您正苦于以下问题:Python User.organization方法的具体用法?Python User.organization怎么用?Python User.organization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.User
的用法示例。
在下文中一共展示了User.organization方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import organization [as 别名]
def create_user():
try:
username = raw_input("Username: ").strip()
email = raw_input("Email: ").strip()
while True:
password = getpass("Password: ")
password_confirm = getpass(" (confirm): ")
if password_confirm == password:
break
else:
print("Passwords do not match... Try again...")
u = User(username=username)
u.email = email
# check for org
org = Organization.get_by_name("default")
if not org:
org = Organization()
org.name = "default"
org.owner = u.uuid
org.save()
u.organization = Organization.get_by_name("default").uuid
u.set_password(password)
u.add_role("admin")
u.save()
print("User created/updated successfully...")
except KeyboardInterrupt:
pass