course_org = CourseOrg.objects.get(id=int(org_id))
all_course = course_org.courseorg_course.all()[:4]
all_teacher = course_org.org_teacher.all()[:1]
return render(request, ‘org-detail-homepage.html’, {
‘all_course’: all_course,
‘all_teacher’: all_teacher,
‘course_org’: course_org,
在模版中
{% for teacher in CourseOrg %}
{{teacher.teacher_course.name}}
{% endfor %}
外键查询,QuerySet
是否是要遍历才能取到值