本文整理汇总了Python中app.user.models.User.create方法的典型用法代码示例。如果您正苦于以下问题:Python User.create方法的具体用法?Python User.create怎么用?Python User.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.user.models.User
的用法示例。
在下文中一共展示了User.create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import create [as 别名]
def register():
"""Register new user."""
form = RegisterForm(request.form, csrf_enabled=False)
if form.validate_on_submit():
User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=True)
flash('Thank you for registering. You can now log in.', 'success')
return redirect(url_for('public.home'))
else:
flash_errors(form)
return render_template('public/register.html', form=form)
示例2: register
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import create [as 别名]
def register():
form = RegisterUserForm()
if form.validate_on_submit():
user = User.create(
username=form.data['username'],
email=form.data['email'],
password=form.data['password'],
remote_addr=request.remote_addr,
)
s = URLSafeSerializer(current_app.secret_key)
token = s.dumps(user.id)
send_registration_email.delay(user, token)
flash(
gettext(
'Sent verification email to {email}'.format(
email=user.email
)
),
'success'
)
return redirect(url_for('index'))
return render_template('register.html', form=form)
示例3: register
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import create [as 别名]
def register():
form = RegisterUserForm()
if form.validate_on_submit():
user = User.create(
username=form.data['username'],
email=form.data['email'],
password=form.data['password'],
)
s = URLSafeSerializer(current_app.secret_key)
token = s.dumps(user.id)
return redirect(url_for('index'))
return render_template('register.html', form=form)
示例4: register
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import create [as 别名]
def register():
form = RegisterUserForm()
user_profile = UserProfile()
if form.validate_on_submit():
user = User.create(
username=form.data['username'],
email=form.data['email'],
password=form.data['password'],
user_profile_id=user_profile.id,
user_profile=user_profile,
)
s = URLSafeSerializer(current_app.secret_key)
token = s.dumps(user.id)
return redirect(url_for('auth.login'))
return render_template('auth/register.html', form=form)
示例5: test_check_password
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import create [as 别名]
def test_check_password(self):
user = User.create(username="foo", email="[email protected]",
password="foobarbaz123")
assert user.check_password('foobarbaz123') is True
assert user.check_password("barfoobaz") is False
示例6: test_check_password
# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import create [as 别名]
def test_check_password(self):
"""Check password."""
user = User.create(username='foo', email='[email protected]',
password='foobarbaz123')
assert user.check_password('foobarbaz123') is True
assert user.check_password('barfoobaz') is False