本文整理汇总了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)