按照老师的讲授写的代码,但是一直报下面这个错误,没有找到原因
Reverse for 'org_course' with arguments '(3,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
代码如下:
url中的配置:
url(r'^org/', include('orgnaization.urls',namespace="org")),
organization中的url配置:
url(r'^home/(?P<org_id>\d+)/$', OrgHomeView.as_view(), name="org_home")
view代码:
class OrgHomeView(View):
def get(self, request, org_id):
course_org = CourseOrg.objects.get(id=int(org_id))
# 反向取出所有的课程
all_courses = course_org.course_set.all()[:3]
all_teachers = course_org.teacher_set.all()[:1]
return render(request, "org-detail-homepage.html", {
"all_courses": all_courses,
"all_teachers": all_teachers,
"course_org": course_org,
})