如何在django中的多table继承中获取父对象

how to get parent object in multi table inheritance in django

我有以下两个使用多重 table 继承的模型。 PlayerAchievment 扩展了 OverallAchievment:

class OverallAchievment(models.Model):
    achievement = models.ForeignKey(Achievement)
    match = models.ForeignKey(Match, limit_choices_to={'week_number': 2})
    created_at = models.DateTimeField(auto_now_add = True)
    updated_at = models.DateTimeField(auto_now = True)


class PlayerAchievement(OverallAchievment):
    player = models.ForeignKey(Player)

    def __unicode__(self):
        return self.player.first_name + ' ' + self.player.last_name

    def match_detail(self):
        ??? how to get match info here?

我想在 PlayerAchievement 子函数中提取有关父项的 match 属性的一些信息。

我该怎么做?

由于 PlayerAchievementOverallAchievment 扩展而来,您可以使用它的属性:

def match_detail(self):
    self.match.<attr_here>
    ...