只需要修改/course/course/1/返回的数 据即可
1.1 course/serializers.py 添加商品信息序列化
from goods.serializers import GoodsSerializer class CourseDeepSerializer(CourseSer): goods_set = GoodsSerializer(many=True) chapters = ChaptersSer(many=True)
1.2 在 goods/serializers.py 中添加序列化函数
# -*- coding: utf-8 -*- from rest_framework import serializers from goods.models import Goods class GoodsSerializer(serializers.ModelSerializer): class Meta: model = Goods fields = '__all__' #所有字段
2测试
http://192.168.56.100:8888/course/course/1/