当前位置: 首页>>代码示例>>Python>>正文


Python User.create方法代码示例

本文整理汇总了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)
开发者ID:iulian4ik,项目名称:HeroesOfProgramming,代码行数:12,代码来源:views.py

示例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)
开发者ID:5290charlie,项目名称:flask-bones,代码行数:28,代码来源:views.py

示例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)
开发者ID:bigdurian1029,项目名称:Foo-Stock,代码行数:15,代码来源:views.py

示例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)
开发者ID:bigdurian1029,项目名称:NULife,代码行数:18,代码来源:views.py

示例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
开发者ID:gabeos,项目名称:docker-flask-template,代码行数:7,代码来源:test_models.py

示例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
开发者ID:iulian4ik,项目名称:HeroesOfProgramming,代码行数:8,代码来源:test_models.py


注:本文中的app.user.models.User.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。