本文整理匯總了Python中products.models.Product.isbn方法的典型用法代碼示例。如果您正苦於以下問題:Python Product.isbn方法的具體用法?Python Product.isbn怎麽用?Python Product.isbn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類products.models.Product
的用法示例。
在下文中一共展示了Product.isbn方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_or_create_product
# 需要導入模塊: from products.models import Product [as 別名]
# 或者: from products.models.Product import isbn [as 別名]
def get_or_create_product(asin):
"""
Checks the database for an existing ASIN. If not found, try to fetch it
using the Amazon Product API.
:return:
An instance of `products.models.Product`
"""
try:
product = Product.objects.get(asin=asin)
except:
amazon = AmazonAPI(settings.AWS_ACCESS_KEY_ID,
settings.AWS_SECRET_ACCESS_KEY,
settings.AWS_ASSOCIATE_TAG)
az = amazon.lookup(ItemId=asin)
product = Product(asin=asin, upc=az.upc, ean=az.ean,
description=az.title, image_url=az.large_image_url,
amazon_url=az.offer_url)
product.save()
generate_thumb.delay(product, '600x400')
generate_thumb.delay(product, '125x125')
product.manufacturer = az.get_attribute('Manufacturer')
product.brand = az.get_attribute('Brand')
product.model_number = az.get_attribute('Model')
product.mpn = az.mpn
product.part_number = az.part_number
product.sku = az.sku
product.isbn = az.isbn
product.length = az.get_attribute('ItemDimensions.Length')
product.width = az.get_attribute('ItemDimensions.Width')
product.height = az.get_attribute('ItemDimensions.Height')
product.weight = az.get_attribute('ItemDimensions.Weight')
product.save()
return product