本文整理汇总了Python中models.Product.type方法的典型用法代码示例。如果您正苦于以下问题:Python Product.type方法的具体用法?Python Product.type怎么用?Python Product.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Product
的用法示例。
在下文中一共展示了Product.type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SaveChanges
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import type [as 别名]
def SaveChanges(self):
for row in self.change_rows.keys():
row = int(row)
product = Product()
product.category = models.ALL_PRODUCT_TYPE[self.m_grid5.GetCellValue(row, 0)]
product.type = self.m_grid5.GetCellValue(row, 1)
product.length = self.m_grid5.GetCellValue(row, 2)
product.width = self.m_grid5.GetCellValue(row, 3)
product.height = self.m_grid5.GetCellValue(row, 4)
product.per_weight = self.m_grid5.GetCellValue(row, 5)
product.price = self.m_grid5.GetCellValue(row, 6)
db.UpdateProduct(product)
for new_row in self.new_products.keys():
product = Product()
product.category = models.ALL_PRODUCT_TYPE[self.m_grid5.GetCellValue(row, 0)]
product.type = self.m_grid5.GetCellValue(new_row, 1)
product.length = self.m_grid5.GetCellValue(new_row, 2)
product.width = self.m_grid5.GetCellValue(new_row, 3)
product.height = self.m_grid5.GetCellValue(new_row, 4)
product.per_weight = self.m_grid5.GetCellValue(new_row, 5)
product.price = self.m_grid5.GetCellValue(new_row, 6)
db.InsertProduct(product)
示例2: GetAllProducts
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import type [as 别名]
def GetAllProducts():
"""获取所有的产品数据"""
db_cur = db_conn.cursor()
db_cur.execute(SQL_ALL_PRODUCT)
all_products = {}
for category in models.ALL_PRODUCT_TYPE.values():
all_products[category] = {}
for row in db_cur:
rec = Product()
rec.category = str(row[0])
rec.type = row[1]
rec.length = str(row[2])
rec.width = str(row[3])
rec.height = str(row[4])
rec.per_weight = str(row[5])
rec.price = str(row[6])
all_products[rec.category][rec.type] = rec
return all_products
示例3: products
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import type [as 别名]
def products(request):
action = request.GET.get('action')
if action == 'criar':
inputNome = request.GET.get('inputNome')
if inputNome is not None:
inputCapacidade = request.GET.get('inputCapacidade')
inputTipo = request.GET.get('inputTipo')
newProduct = Product()
newProduct.name = inputNome
newProduct.capacity = inputCapacidade
newProduct.type = inputTipo[0]
newProduct.creation_date = datetime.datetime.now()
newProduct.save()
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar',
'status': 'created'})
return render(request, 'SisLocApp/products.html', {'action': 'criar'})
elif action == 'excluir':
inputExcluir = request.GET.get('inputExcluir')
ProductDeleted = Product.objects.filter(id=inputExcluir)
ProductDeleted.delete()
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar',
'status': 'deleted'})
elif action == 'alterar':
inputAlterar = request.GET.get('inputAlterar')
ProductsResult = Product.objects.get(id=inputAlterar)
inputNome = request.GET.get('inputNome')
if inputNome is None:
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'alterar'})
inputCapacidade = request.GET.get('inputCapacidade')
inputTipo = request.GET.get('inputTipo')
ProductsResult.name = inputNome
ProductsResult.capacity = inputCapacidade
ProductsResult.type = inputTipo[0]
ProductsResult.save()
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar',
'status': 'updated'})
else:
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar'})