本文整理匯總了Python中products.models.Product.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Product.create方法的具體用法?Python Product.create怎麽用?Python Product.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類products.models.Product
的用法示例。
在下文中一共展示了Product.create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: from products.models import Product [as 別名]
# 或者: from products.models.Product import create [as 別名]
def setUp(self):
"""
Set up for the Acknowledgement Test
Objects created:
-User
-Customer
-Supplier
-Address
-product
-2 fabrics
After Creating all the needed objects for the Acknowledgement,
test that all the objects have been made.
"""
super(ShippingResourceTest, self).setUp()
self.ct = ContentType(app_label="shipping")
self.ct.save()
#Create the user
self.username = 'tester'
self.password = 'pass'
self.user = User.objects.create_user(self.username, '[email protected]', self.password)
self.user.save()
p = Permission(content_type=self.ct, codename="change_shipping")
p.save()
p2 = Permission(content_type=self.ct, codename="add_shipping")
p2.save()
self.user.user_permissions.add(p)
self.user.user_permissions.add(p2)
self.user.save()
self.setup_client()
#Create supplier, customer and addrss
self.customer = Customer(**base_customer)
self.customer.save()
self.supplier = Supplier(**base_supplier)
self.supplier.save()
self.address = Address(address1="Jiggle", contact=self.customer)
self.address.save()
#Create project
self.project = Project.objects.create(codename="Ladawan")
#Create phase
self.phase = Phase.objects.create(description="Phase 1/6", project=self.project)
#Create a product to add
self.product = Product.create(self.user, **base_product)
self.product.save()
self.fabric = Fabric.create(**base_fabric)
f_data = base_fabric.copy()
f_data["pattern"] = "Stripe"
self.fabric2 = Fabric.create(**f_data)
#Create acknowledgement
ack_data = base_ack.copy()
del ack_data['customer']
del ack_data['items']
del ack_data['employee']
self.ack = Acknowledgement(**ack_data)
self.ack.customer = self.customer
self.ack.employee = self.user
self.ack.save()
#Create an item
item_data = {'id': 1,
'quantity': 1,
'is_custom_size': True,
'width': 1500,
"fabric": {"id":1}}
self.item = AckItem.create(acknowledgement=self.ack, **item_data)
#Create an item
item_data = {'id': 1,
'quantity': 2,
'is_custom_size': True,
'width': 1500,
"fabric": {"id":1}}
self.item2 = AckItem.create(acknowledgement=self.ack, **item_data)