1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
from rest_framework import serializers from . import models class CourseCategorySerializer(serializers.ModelSerializer): classMeta: model = models.CourseCategory fields = ('id', 'name')
# 子序列化 classTeacherSerializer(serializers.ModelSerializer): classMeta: model = models.Teacher fields = ('name', 'role_name', 'title', 'signature', 'image', 'brief')
classCourseSerializer(serializers.ModelSerializer): teacher = TeacherSerializer(many=False)
classMeta: model = models.Course fields = ( 'id', 'name', 'course_img', 'brief', 'attachment_path', 'pub_sections', 'price', 'students', 'period', 'sections', 'course_type_name', 'level_name', 'status_name', 'teacher', 'section_list', )
|