当前位置: 首页>>代码示例>>Python>>正文


Python Model.get方法代码示例

本文整理汇总了Python中Model.Model.get方法的典型用法代码示例。如果您正苦于以下问题:Python Model.get方法的具体用法?Python Model.get怎么用?Python Model.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.Model的用法示例。


在下文中一共展示了Model.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Category

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
			'Prince Edward': {}
		}
	}
}

c = Category()
c.name = 'Root'
c.save()
c.makeTree()

for (category,children) in categories.items():
	catFill(category, children, c)

# create product and assign to category

categories = Model.get(Category)

i = 0
while i < 100:
	p = Product()
	# when these save, Category relationship saving messes up
	p.name = ''.join(random.sample('abcdefghijklmnopqrstuvwxyz ', 15))
	p.description = ''.join(random.sample('abcdefghijklmnopqrstuvwxyz ', 20))
	p.price = str(decimal.Decimal(random.randrange(10000))/100)

	category = random.sample(categories, 1)[0]

	p.Category = category
	p.save()

	i += 1
开发者ID:alanszlosek,项目名称:data-type-tables,代码行数:33,代码来源:00.populate.py

示例2: print

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
from Model import Model
from boot import *

print('Print Product ids for each Category')

for category in Model.get(Category):
	print(category.name)
	for product in category.Product:
		print('\t' + product.id, product.name)


Model.done()
开发者ID:alanszlosek,项目名称:data-type-tables,代码行数:14,代码来源:04.many-related.py

示例3: print

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
from Model import Model
from boot import *

print('Get first Product, print Category name if any')

products = Model.get(Product)

p = products[0]
print('Product ' + p.id)
cat = p.Category
if cat:
	print(p.Category.id)
else:
	print('No Category')

Model.done()
开发者ID:alanszlosek,项目名称:data-type-tables,代码行数:18,代码来源:03.one-related.py

示例4: get

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import get [as 别名]
 def get(self, itemid):
     imglink = Model.get(self,itemid)
     if imglink is not None:
         img = Image().get(imglink.Imageid)
         imglink['uri'] = img.uri if img is not None else ''
     return imglink
开发者ID:ajiexw,项目名称:old-zarkpy,代码行数:8,代码来源:ImgLink.py


注:本文中的Model.Model.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。