【发布时间】:2018-02-24 23:34:43
【问题描述】:
在 django 模型中,我有 2 个类;国家和大陆。每个国家都通过外键链接到大陆。
class Continent(models.Model):
countries = [get countries that are linked to this continent here]
class Country(models.Model):
continent = models.ForeignKey(Continent)
如何在国家属性中获取关联国家/地区?
在 shell 中我可以使用
Country.objects.get()
但似乎我不能在另一个类的属性中使用类名 Country。
【问题讨论】: