我有以下两种模式:
class StraightredTeam(models.Model):
teamid = models.IntegerField(primary_key=True)
teamname = models.CharField(max_length=36)
teamcode = models.CharField(max_length=5)
teamshortname = models.CharField(max_length=24)
currentteam = models.PositiveSmallIntegerField()
def natural_key(self):
return self.teamshortname
class Meta:
managed = True
db_table = 'straightred_team'
class StraightredFixture(models.Model):
fixtureid = models.IntegerField(primary_key=True)
soccerseason = models.IntegerField(db_column='soccerSeason') # Field name made lowercase.
home_team = models.ForeignKey('straightred.StraightredTeam', db_column='hometeamid', related_name='home_fixtures')
away_team = models.ForeignKey('straightred.StraightredTeam', db_column='awayteamid', related_name='away_fixtures')
fixturedate = models.DateTimeField()
fixturestatus = models.CharField(max_length=24)
fixturematchday = models.IntegerField()
hometeamscore = models.IntegerField()
awayteamscore = models.IntegerField()
class Meta:
managed = True
db_table = 'straightred_fixture'
以下网站以xml格式提供足球赛程/结果如下:
注意:本网站可能会暂时下降! SORRY。
http://api.football-data.org/alpha/soccerseasons/398/fixtures
我有兴趣了解将xml文件操作到上面显示的数据库模型中的最佳方法。
我假设某种循环,但我想知道是否有人能指出我正确的方向或链接到一个例子。
非常感谢任何帮助,非常感谢,Alan。