class GoodsCategoryListViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
"""
List:
分类列表
"""
queryset = GoodsCategory.objects.filter(category_type=1)
serializer_class = GoodsCategorySerializer
因为queryset 指定了category_type=1, 当我们http://127.0.0.1:8000/category/7/ 访问一个三级分类的时候,会提示
HTTP 404 Not Found
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
{
"detail": "未找到。"
}
Django REST framework课程视频,RESTFul API前后端分离开发
了解课程