本文整理汇总了Python中forms.PageForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python PageForm.validate_on_submit方法的具体用法?Python PageForm.validate_on_submit怎么用?Python PageForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.PageForm
的用法示例。
在下文中一共展示了PageForm.validate_on_submit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_page
# 需要导入模块: from forms import PageForm [as 别名]
# 或者: from forms.PageForm import validate_on_submit [as 别名]
def edit_page(nickname, pagename):
if nickname != g.user.nickname:
flash('Cannot edit another users content page.')
return redirect(url_for('index'))
user_page = g.user.user_page(pagename)
if user_page == None:
flash('Content page doesn''t exist')
return redirect(url_for('index'))
form = PageForm()
if form.validate_on_submit():
user_page.page_title = form.page_title.data
user_page.page_content = form.page_content.data
db.session.add(user_page)
db.session.commit()
flash('Updated content page successfully!')
return redirect(url_for('index'))
else:
form.page_title.data = user_page.page_title
form.page_content.data = user_page.page_content
return render_template('page_form.html',
form = form)
示例2: pages
# 需要导入模块: from forms import PageForm [as 别名]
# 或者: from forms.PageForm import validate_on_submit [as 别名]
def pages():
form = PageForm()
if form.validate_on_submit():
page = Page(page_title = form.page_title.data, page_content = form.page_content.data, user_id = g.user.id)
db.session.add(page)
db.session.commit()
flash('Your page has been added!')
return redirect(url_for('index'))
return render_template('page_form.html',
form = form)