本文整理匯總了Python中forms.ProductForm.validate_on_submit方法的典型用法代碼示例。如果您正苦於以下問題:Python ProductForm.validate_on_submit方法的具體用法?Python ProductForm.validate_on_submit怎麽用?Python ProductForm.validate_on_submit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類forms.ProductForm
的用法示例。
在下文中一共展示了ProductForm.validate_on_submit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: admin
# 需要導入模塊: from forms import ProductForm [as 別名]
# 或者: from forms.ProductForm import validate_on_submit [as 別名]
def admin():
form = LoginForm()
prod = ProductForm()
if prod.validate_on_submit():
new = Product(name=prod.name.data, stock=prod.stock.data, image=prod.image.data, price=prod.price.data)
db.session.add(new)
db.session.commit()
flash('Product Added!')
return redirect(url_for('store'))
return render_template('admin.html', prod=prod, form=form)
示例2: editProduct
# 需要導入模塊: from forms import ProductForm [as 別名]
# 或者: from forms.ProductForm import validate_on_submit [as 別名]
def editProduct(prod_id):
prodForm = ProductForm()
prod = Product.query.get(prod_id)
if prodForm.validate_on_submit():
prod.name=prodForm.name.data
prod.category = prodForm.category.data
prod.note=prodForm.note.data
prod.size = prodForm.size.data
prod.unit=prodForm.unit.data
db.session.commit()
return redirect(url_for('shopapp.shop_main'))
示例3: newProduct
# 需要導入模塊: from forms import ProductForm [as 別名]
# 或者: from forms.ProductForm import validate_on_submit [as 別名]
def newProduct():
prodForm = ProductForm()
name = prodForm.name.data
if prodForm.validate_on_submit():
if Product.query.filter_by(name=name).first():
flash('Product with this name already exists!', 'alert-danger')
else:
prod = Product(name=name, category = prodForm.category.data, note=prodForm.note.data, size = prodForm.size.data, unit=prodForm.unit.data)
db.session.add(prod)
db.session.commit()
return redirect(redirect_url())
return redirect(url_for('shopapp.shop_main'))