如何在python中将复杂对象序列化为JSON

时间:2018-06-11 10:08:02

标签: python django

我有复杂的对象,其他对象的复合列表。 我将此对象序列化为JSON值以执行创建viewModel。

class refereereport(Model):
    competition = models.ForeignKey(competition, on_delete=models.CASCADE)
    reportdate = models.CharField(max_length=10)
    reporttime = models.CharField(max_length=10)
    reviewerreferee = models.ForeignKey(reviewer, on_delete=models.CASCADE)
    federationdeletage = models.CharField(max_length=100)
    longdescriptions = models.TextField()
    isdelete = models.BooleanField()

class competitionreferee(Model):
    competitionkey = models.ForeignKey(competition, on_delete=models.CASCADE)
    referee = models.ForeignKey(referee, on_delete=models.CASCADE)
    type = models.CharField(max_length=30, choices=refereemebers)

0 个答案:

没有答案