本文整理汇总了Python中products.models.Product.title方法的典型用法代码示例。如果您正苦于以下问题:Python Product.title方法的具体用法?Python Product.title怎么用?Python Product.title使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类products.models.Product
的用法示例。
在下文中一共展示了Product.title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _product
# 需要导入模块: from products.models import Product [as 别名]
# 或者: from products.models.Product import title [as 别名]
def _product(self, item):
try:
product = Product.objects.get(wholesale_legacy_id=int(item['id']), is_visible=True)
except Product.DoesNotExist:
product = Product()
except Product.MultipleObjectsReturned:
print item['id']
for p in Product.objects.filter(wholesale_legacy_id=int(item['id'])):
print p.id, p.title, p.code, p.sku
print '-----'
raise
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.wholesale_legacy_id = item['id']
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
示例2: _product
# 需要导入模块: from products.models import Product [as 别名]
# 或者: from products.models.Product import title [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