本文整理匯總了Python中products.models.Product.is_wholesale方法的典型用法代碼示例。如果您正苦於以下問題:Python Product.is_wholesale方法的具體用法?Python Product.is_wholesale怎麽用?Python Product.is_wholesale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類products.models.Product
的用法示例。
在下文中一共展示了Product.is_wholesale方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _product
# 需要導入模塊: from products.models import Product [as 別名]
# 或者: from products.models.Product import is_wholesale [as 別名]
def _product(self, item):
try:
product = Product.objects.get(id=int(item['id']))
except Product.DoesNotExist:
product = Product(id=int(item['id']))
quantity = int(item.get('qtyi', 0))
if quantity < 0:
quantity = 0
weight = int(item.get('weight', 0))
if weight < 0:
weight = 0
product.sku = item['article']
product.weight = weight
product.quantity = quantity
product.code = item['link']
product.title = item['name']
product.description = item['descr']
product.is_visible = bool(int(item['pub']))
product.is_wholesale = False
product.created = TIMEZONE.localize(datetime.datetime.fromtimestamp(int(item['dt'])))
size = None
try:
size = SIZE_RE.findall(u' '.join([item['name'], item.get('alt', ''), item['descr']]))[0]
except IndexError:
try:
size = SIZE2_RE.findall(u' '.join([item['name'], item.get('alt', ''), item['descr']]))[0]
except IndexError:
pass
if size:
product.size = u'×'.join([str(x) for x in size])
return product