本文整理汇总了Python中treemap.models.User.save_base方法的典型用法代码示例。如果您正苦于以下问题:Python User.save_base方法的具体用法?Python User.save_base怎么用?Python User.save_base使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.User
的用法示例。
在下文中一共展示了User.save_base方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import save_base [as 别名]
def handle(self, *args, **options):
try:
model_id = settings.SYSTEM_USER_ID
except AttributeError:
print('The `SYSTEM_USER_ID` settings is missing from '
'the settings file. Set this to a specific ID '
'before running this command.')
return
system_user_name = 'System User'
existing_users = User.objects.filter(pk=model_id)
users_with_name = User.objects.filter(username=system_user_name)
if len(existing_users) == 1 and len(users_with_name) == 1:
print('System user already exists')
elif len(users_with_name) > 0:
print('A user with username "%s" already exists but is not '
'a super user' % system_user_name)
else:
user = User(is_active=False,
username=system_user_name,
pk=model_id)
user.save_base()
print('Created system user')
示例2: create_mock_system_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import save_base [as 别名]
def create_mock_system_user():
try:
system_user = User.objects.get(id=settings.SYSTEM_USER_ID)
except Exception:
system_user = User(username="system_user",
email='[email protected]')
system_user.id = settings.SYSTEM_USER_ID
system_user.set_password('password')
system_user.save_base()
User._system_user = system_user