本文整理汇总了Python中models.Team.key方法的典型用法代码示例。如果您正苦于以下问题:Python Team.key方法的具体用法?Python Team.key怎么用?Python Team.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Team
的用法示例。
在下文中一共展示了Team.key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import key [as 别名]
def get(self, first_eid):
df = DatafeedUsfirstEvents()
event = df.getEvent(first_eid)
event = EventUpdater.createOrUpdate(event)
teams = df.getEventRegistration(first_eid)
eventteams_count = 0
for team_dict in teams:
# This could be refactored to do a lot fewer DB requests by batching the Team and EventTeam gets.
# -gregmarra 5 Dec 2010
team = Team.get_by_key_name("frc" + str(team_dict["number"]))
if team is None:
team = Team(
team_number = int(team_dict["number"]),
first_tpid = int(team_dict["tpid"]),
key_name = "frc" + str(team_dict["number"])
)
team.put()
et = EventTeam.get_or_insert(
key_name = event.key().name() + "_" + team.key().name(),
event = event,
team = team)
eventteams_count = eventteams_count + 1
template_values = {
'event': event,
'eventteams_count': eventteams_count,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_event_get.html')
self.response.out.write(template.render(path, template_values))
示例2: register_team
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import key [as 别名]
def register_team(request):
serialized = TeamSerializer(data=request.DATA)
team = Team()
team.name = serialized.init_data['name']
team.email = serialized.init_data['email']
team.key = "something"
team.save()
return Response(TeamSerializer(team).data, status=status.HTTP_201_CREATED)