Django select 相关的 select 相关的

Django select related of select related

我有一个 Student 模型,它有一个指向 School 模型(相关名称是 school)的外键国家/地区 模型(相关名称为 country)本身具有 FK。

我想要 select Student 及其学校和国家。 我需要这样写吗:

student = Student.objects.filter(pk=123).select_related("school", "school__country").first()
student.school # use object cache
student.school.country # use object cache

或者这样就够了:

student = Student.objects.filter(pk=123).select_related("school__country").first()

不,school__country 版本意味着还需要选择 school