本文整理汇总了Python中models.Player.price方法的典型用法代码示例。如果您正苦于以下问题:Python Player.price方法的具体用法?Python Player.price怎么用?Python Player.price使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.price方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_players
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import price [as 别名]
def update_players():
'''
Updates the Player table with the json retrieved from Kimono.
If a player is not in the table it creates one.
Returns the number of new palyers added to the db
'''
logger.info('Updating players...')
url = settings.KIMONO['players_url']
players = _get_results_collection1(url)
logger.info(' - Updating database...')
no_new_players = 0
for player in players:
p = Player()
# If the player is already in the db, using the same pk end up updating
# the past value
p.id = _id_from_url(player['name']['href'])
if not Player.objects.filter(pk=p.id).exists():
no_new_players += 1
p.name = player['name']['text']
p.role = _fix_role(player['role'])
p.team = Team.objects.get(name__iexact=player['team'])
p.price = player['price']
# Replacing the '-' character with 0 in remaining fields
p.attendances = _fix_zero(player['attendances'])
p.gol = _fix_zero(player['gol'])
p.assist = _fix_zero(player['assist'])
p.yellow_cards = _fix_zero(player['yellow_cards'])
p.red_cards = _fix_zero(player['red_cards'])
p.penalties_kicked = _fix_zero(player['penalties_kicked'])
p.penalties_scored = _fix_zero(player['penalties_scored'])
p.penalties_missed = _fix_zero(player['penalties_missed'])
p.penalties_saved = _fix_zero(player['penalties_saved'])
p.vote_avg = _fix_zero(player['vote_avg'])
p.magicvote_avg = _fix_zero(player['magicvote_avg'])
# Storing on the db
p.save()
return no_new_players