1、编辑usercenter-mycourse.html继承usercenter-base.html
2、编辑users.views.py
... from operation.models import UserCourse from courses.models import Course class MyCourseView(LoginRequiredMixin, View): def get(self, request): user_courses = UserCourse.objects.filter(user=request.user) course_ids = [user_course.id for user_course in user_courses] courses = Course.objects.filter(id__in=course_ids) return render(request, 'usercenter-mycourse.html', { 'courses': courses })
3、编辑users.urls.py
... from .views import MyCourseView urlpatterns = [ ... url(r'my_course/$', MyCourseView.as_view(), name='my_course'), ]
4、编辑usercenter-base.html中的导航链接
5、编辑usercenter-mycourse.html动态数据展示