Ejemplo n.º 1
0
 def get(self, request, pk, *args, **kwargs):
     ret = response.BaseResponse()
     queryset = models.DegreeCourse.objects.get(pk=pk)
     ser = serializers.DegreecourseModuleSerializer(instance=queryset)
     print(type(ser.data))
     ret.data = ser.data
     return Response(ret.dict)
Ejemplo n.º 2
0
 def get(self, request, *args, **kwargs):
     ret = response.BaseResponse()
     queryset = models.DegreeCourse.objects.all()
     print(queryset)
     page = PageNumberPagination()
     print(page)
     course_list = page.paginate_queryset(queryset, request, self)
     print(course_list)
     ser = serializers.DegreecourseTeacherSerializer(instance=course_list, many=True)
     ret.data = ser.data
     return Response(ret.dict)
Ejemplo n.º 3
0
    def get(self, request, *args, **kwargs):
        ret = response.BaseResponse()
        try:
            queryset = models.Course.objects.all()
            page = PageNumberPagination()
            course_list = page.paginate_queryset(queryset, request, self)
            course_ser = course.CourseModelSerializer(instance=course_list,
                                                      many=True)
            ret.data = course_ser.data
        except Exception as e:
            ret.code = 500
            ret.error = "获取数据失败"

        return Response(ret.dict)
Ejemplo n.º 4
0
    def get(self, request, *args, **kwargs):
        ret = response.BaseResponse()
        try:
            # 查看所有学位课并打印学位课名称以及授课老师
            queryset = models.DegreeCourse.objects.all().values(
                "name", "teachers__name")

            # 查看所有学位课并打印学位课名称以及学位课的奖学金
            # queryset = models.DegreeCourse.objects.all()

            # 展示所有的专题课
            # queryset = models.Course.objects.filter(degree_course__isnull=False)

            # 查看id=1的学位课对应的所有模块名称
            # queryset = models.Course.objects.filter(degree_course_id = 1)

            # 获取id = 1的专题课,并打印:课程名、级别(中文)、why_study、what_to_study_brief、所有recommend_courses
            # queryset = models.Course.objects.filter(id=1).first()    # 去掉many=True

            # 获取id = 1的专题课,并打印该课程相关的所有常见问题
            # queryset = models.Course.objects.filter(id=1).first()

            # 获取id = 1的专题课,并打印该课程相关的课程大纲
            # queryset = models.Course.objects.filter(id=1).first()

            # 获取id = 1的专题课,并打印该课程相关的所有章节
            # queryset = models.Course.objects.filter(id=1).first()

            # page = PageNumberPagination()
            # lis = page.paginate_queryset(queryset,request,self)
            obj = test.DemoModelSerializer(instance=queryset, many=True)
            ret.data = obj.data
        except Exception as e:
            ret.code = 500
            ret.error = "获取数据失败"
        return Response(ret.dict)
Ejemplo n.º 5
0
 def get(self, request, pk, *args, **kwargs):
     res = response.BaseResponse()
     queryset = models.Course.objects.get(pk=pk)
     ser = serializers.CourseQASerializer(instance=queryset)
     res.data = ser.data
     return Response(res.dict)
Ejemplo n.º 6
0
 def get(self, request, *args, **kwargs):
     ret = response.BaseResponse()
     queryset = models.Course.objects.filter(degree_course__isnull=True)
     ser = serializers.AllCourseSerializer(instance=queryset, many=True)
     ret.data = ser.data
     return Response(ret.data)
Ejemplo n.º 7
0
 def get(self, request, *args, **kwargs):
     ret = response.BaseResponse()
     queryset = models.DegreeCourse.objects.all()
     ser = serializers.DegreecourseScholarshipSerializer(instance=queryset, many=True)
     ret.data = ser.data
     return Response(ret.dict)