一 实现商品数据库数据的序列化展示 和字段类别展示
1.good/serializers.py 商品类别的序列化类

2.goods/views.py
在views.py中实现商品分类 得到商品的所有数据并且得到所有字段 引入 CategorySerializers类


3.SxShop/urls.py 路由导入 分类页面展示 CategoryViewSet


二 数据分类分析 CategoryType分类 与models中的GoodsCategory中的字段相互映射与展示

1.三级分类的父级分类和子级分类 作为外键 设置一个相关名称 related_name



2.获取某一个具体类的详情页面信息



在goods/views.py中的CategoryViewSet中只需要 继承自mixin的RetriveModelMixin即可


网友评论