Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django Python MySQL结果操作_Python_Mysql_Django - Fatal编程技术网

Django Python MySQL结果操作

Django Python MySQL结果操作,python,mysql,django,Python,Mysql,Django,我有一个django设置,其工作原理如下: 观点: def jsonfixture(request, soccerseason, fixturematchday): data = StraightredFixture.objects.filter(soccerseason=soccerseason,fixturematchday=fixturematchday) json_data = serializers.serialize('json', data, use_natural_forei

我有一个django设置,其工作原理如下:

观点:

def jsonfixture(request, soccerseason, fixturematchday):

data = StraightredFixture.objects.filter(soccerseason=soccerseason,fixturematchday=fixturematchday)

json_data = serializers.serialize('json', data, use_natural_foreign_keys=True)

return HttpResponse(json_data, content_type='application/json')
模型:

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')

    class Meta:
        managed = False
        db_table = 'straightred_fixture'
每一场比赛都有主客场比赛。即

第一队对第四队

第三队对第二队

我希望能够操作返回的数据,并以如下形式创建一个下拉列表:

第一队主场对第四队

第二队客场对第三队

第三队主场对第二队

第四队客场对第一队

我希望这有意义?如果您有任何问题,请让我知道,我会立即答复。非常感谢您提供的任何帮助或建议


艾伦。

以下YouTube视频引导我了解了整个过程,并帮助我了解了整个过程:

希望这对将来的人有所帮助:)