📜  github hacksofteare - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:26.583000             🧑  作者: Mango

代码示例3
class CourseListApi(SomeAuthenticationMixin, APIView):
    class OutputSerializer(serializers.ModelSerializer):
        class Meta:
            model = Course
            fields = ('id', 'name', 'start_date', 'end_date')

    def get(self, request):
        courses = get_courses()

        serializer = self.OutputSerializer(courses, many=True)

        return Response(serializer.data)