标签:image pre djang 根据 retrieve view lin info lis
class CourseView(GenericViewSet, RetrieveModelMixin):
queryset = models.Course.objects.filter(is_delete=False, is_show=True).order_by(‘orders‘)
serializer_class = serializer.CourseModelSerializer
class CourseChapterView(GenericViewSet,ListModelMixin):
queryset = models.CourseChapter.objects.filter(is_delete=False,is_show=True)
serializer_class = serializer.CourseChapterSerializer
# 可以根据课程ID来查
filter_backends = [DjangoFilterBackend]
filter_fields = [‘course‘] # 根据课程来过滤课时
# CourseChapterSerializer
class CourseSectionSerializer(serializers.ModelSerializer):
class Meta:
model=models.CourseSection
fields = [‘name‘,‘orders‘,‘duration‘,‘free_trail‘,‘section_link‘,‘section_type_name‘]
class CourseChapterSerializer(serializers.ModelSerializer):
# 子序列化列
coursesections =CourseSectionSerializer(many=True)
class Meta:
model = models.CourseChapter
fields = [‘name‘,‘summary‘,‘chapter‘,‘coursesections‘]
标签:image pre djang 根据 retrieve view lin info lis
原文地址:https://www.cnblogs.com/surpass123/p/13393975.html