本文整理汇总了Python中models.Profile.create方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.create方法的具体用法?Python Profile.create怎么用?Python Profile.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import create [as 别名]
def post(self, **kwargs):
redirect_url = self.redirect_path()
if self.auth_current_user:
return redirect(redirect_url)
if self.form.validate():
username = self.form.username.data
password = self.form.password.data
password_confirm = self.form.password_confirm.data
email = self.form.email.data
email_confirm = self.form.email_confirm.data
if password != password_confirm:
self.set_message('error', 'Password doesnt match', life=None)
return self.get(**kwargs)
if email != email_confirm:
self.set_message('error', 'E-mail doesnt match', life=None)
return self.get(**kwargs)
auth_id = 'own|%s' % username
user = self.auth_create_user(username, auth_id, password=password, email=email)
if user:
profile = Profile.create(user.key())
if profile:
url = '/mail/verify/%s/' % user.key()
task = taskqueue.add(url=url, method='GET')
self.auth_set_session(user.auth_id, user.session_id, '1')
self.set_message('success', 'You are now registered', flash=True, life=5)
return redirect(redirect_url)
else:
self.set_message('error', 'This username is taken', life=None)
return self.get(**kwargs)
self.set_message('error', 'A problem occurred!', life=None)
return self.get(**kwargs)
示例2: create_one_user_profile
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import create [as 别名]
def create_one_user_profile(self, username, email, password):
user = User.objects.create_user(username, email, password)
user.save()
profile = Profile.create(user)
return profile