本文整理汇总了Python中accounts.models.UserProfile.verification_code方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.verification_code方法的具体用法?Python UserProfile.verification_code怎么用?Python UserProfile.verification_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.verification_code方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_new_user
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import verification_code [as 别名]
def create_new_user(email, name = None):
ups = UserProfile.objects.filter(email = email)
if len(ups) > 0:
print (len(ups))
print ("User(s) with email {} already exists, aborting user creation!".
format(email))
return None
username = new_user_name()
user = User.objects.create_user(username, email = None, password = None)
user.is_active = True
user.is_staff = False
user.is_superuser = False
# The following fields are fields we store in the UserProfile object instead
# user.first_name
# user.last_name
# user.email
user.save()
up = UserProfile()
up.user = user
up.password_is_set = False
up.magic_login_code = random.randint(100000000, 999999999)
# If the user doesn't specify a name, email is used as the default
if name is None:
up.name = email
else:
up.name = name
up.email = email
up.phone = ''
up.verification_code = new_phone_verification_number()
up.is_verified = False
up.state = 'CA'
up.message_frequency = 3
up.forecast_email = False
up.set_equipment([])
up.beta_test = True
# In the future, we should separate phone-number, etc., into a separate model
up.save()
print ("User {} created.".format(email))
return user