本文整理汇总了Python中forms.UserCreateForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python UserCreateForm.validate_on_submit方法的具体用法?Python UserCreateForm.validate_on_submit怎么用?Python UserCreateForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.UserCreateForm
的用法示例。
在下文中一共展示了UserCreateForm.validate_on_submit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import validate_on_submit [as 别名]
def post(self):
form = UserCreateForm()
if not form.validate_on_submit():
return form.errors, 422
user = User(form.email.data, form.password.data)
db.session.add(user)
db.session.commit()
return UserSerializer(user).data
示例2: login
# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import validate_on_submit [as 别名]
def login():
form = LoginForm()
formCreate=UserCreateForm()
providers = ["Facebook", "Google", "Twitter"]
erromsg=""
if form.validate_on_submit() or form.provider.data=="facebook":
provider = form.provider.data
session['remember_me'] = form.remember_me.data
session['provider'] = provider
if provider == "google":
callback=url_for('account.google_authorized', _external=True)
return google.authorize(callback=callback)
elif provider == "twitter":
callback=url_for('account.twitter_authorized',
next=request.args.get('next') or request.referrer or None,
_external=True)
return twitter.authorize(callback=callback)
elif provider == "facebook":
callback=url_for('account.facebook_authorized',
next=request.args.get('next') or request.referrer or None,
_external=True)
return facebook.authorize(callback=callback)
else:
if form.password is not None:
return after_login( email=form.email.data,
password=form.password.data)
if formCreate.validate_on_submit():
return after_login(fullname=formCreate.fullname.data, nickname=formCreate.nickname.data,
language="pt", country="br", image="image",email=formCreate.email.data,
password=formCreate.password.data)
return render_template('account/login.html',
form = form,formCreate=formCreate,
providers = providers)