本文整理汇总了Python中models.Score.get_or_insert方法的典型用法代码示例。如果您正苦于以下问题:Python Score.get_or_insert方法的具体用法?Python Score.get_or_insert怎么用?Python Score.get_or_insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Score
的用法示例。
在下文中一共展示了Score.get_or_insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import get_or_insert [as 别名]
def index():
den = Score.get_or_insert('den', name='Denver', amount=0)
sea = Score.get_or_insert('sea', name='Seattle', amount=0)
goal = 6500 * 100.0
if den.amount < goal and sea.amount < goal:
den_factor = den.amount * 100.0 / goal
sea_factor = sea.amount * 100.0 / goal
else:
den_factor = 100
sea_factor = 100
if den.amount > sea.amount:
sea_factor = sea.amount * 100.0 / den.amount
elif sea.amount > den.amount:
den_factor = den.amount * 100.0 / sea.amount
return render_template('index.html', den=den, sea=sea, den_factor=den_factor, sea_factor=sea_factor)