本文整理汇总了Python中models.Product.subcategory_desc方法的典型用法代码示例。如果您正苦于以下问题:Python Product.subcategory_desc方法的具体用法?Python Product.subcategory_desc怎么用?Python Product.subcategory_desc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Product
的用法示例。
在下文中一共展示了Product.subcategory_desc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addProduct
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import subcategory_desc [as 别名]
def addProduct():
form = AddProductForm()
makers = Maker.query.all()
if makers:
form.maker.choices = [(a.id, a.name) for a in makers]
if form.validate_on_submit():
product = Product()
product.code = form.code.data
product.maker_id = form.maker.data
product.maker_code = form.maker_code.data
product.desc_CS = form.desc_CS.data
product.desc_JP = form.desc_JP.data
product.long_desc = form.long_desc.data
product.detailed_desc = form.detailed_desc.data
product.subcategory_desc = form.subcategory_desc.data
product.keywords = form.keywords.data
product.price_unit = form.price_unit.data
product.price_retail = form.price_retail.data
product.qty_stock = form.qty_stock.data
product.limited_flg = form.limited_flg.data
product.axm_node = form.axm_node.data
if form.package_size.data == '':
product.package_size = None
else:
product.package_size = form.package_size.data
category_id = Maker.query.filter_by(id=product.maker_id).first().category_id
if category_id:
product.category_id = category_id
db.session.add(product)
db.session.commit()
term_ids_str = request.form.getlist('term')
for id in term_ids_str:
t = CatalogedProducts()
t.product_id = product.id
t.catalog_id = int(id)
db.session.add(t)
db.session.commit()
flash(gettext("New product successfully added."))
return redirect(url_for("editProduct", id=product.id))
catalog = prepare_catalog()
return render_template("product/addProduct.html",
title=gettext('Add new product'),
catalog=catalog,
form=form)