本文整理汇总了Python中student.models.UserProfile.__setattr__方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.__setattr__方法的具体用法?Python UserProfile.__setattr__怎么用?Python UserProfile.__setattr__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.__setattr__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_user
# 需要导入模块: from student.models import UserProfile [as 别名]
# 或者: from student.models.UserProfile import __setattr__ [as 别名]
def import_user(u):
user_info = u["u"]
up_info = u["up"]
# HACK to handle dates
user_info["last_login"] = dateutil.parser.parse(user_info["last_login"])
user_info["date_joined"] = dateutil.parser.parse(user_info["date_joined"])
user_keys = [
"id",
"username",
"email",
"password",
"is_staff",
"is_active",
"is_superuser",
"last_login",
"date_joined",
"password",
]
up_keys = ["language", "location", "meta", "name", "id", "user_id"]
u = User()
for key in user_keys:
u.__setattr__(key, user_info[key])
u.save()
up = UserProfile()
up.user = u
for key in up_keys:
up.__setattr__(key, up_info[key])
up.save()
示例2: import_user
# 需要导入模块: from student.models import UserProfile [as 别名]
# 或者: from student.models.UserProfile import __setattr__ [as 别名]
def import_user(u):
user_info = u['u']
up_info = u['up']
# HACK to handle dates
user_info['last_login'] = dateutil.parser.parse(user_info['last_login'])
user_info['date_joined'] = dateutil.parser.parse(user_info['date_joined'])
user_keys = ['id', 'username', 'email', 'password', 'is_staff',
'is_active', 'is_superuser', 'last_login', 'date_joined',
'password']
up_keys = ['language', 'location', 'meta', 'name', 'id', 'user_id']
u = User()
for key in user_keys:
u.__setattr__(key, user_info[key])
u.save()
up = UserProfile()
up.user = u
for key in up_keys:
up.__setattr__(key, up_info[key])
up.save()