摘要: 参考官网文档 https://www.django-rest-framework.org/topics/documenting-your-api/ url文件中添加 from rest_framework.documentation import include_docs_urls urlpatte 阅读全文
posted @ 2021-12-22 19:02 Jessie橙子 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 商品的view # 加上RetrieveModelMixin即可 class GoodsListViewSet(mixins.ListModelMixin,mixins.RetrieveModelMixin, viewsets.GenericViewSet): """ 商品列表页,分页,搜索,过滤, 阅读全文
posted @ 2021-12-17 18:07 Jessie橙子 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 问题现象 Error in render: "TypeError: Cannot read properties of null (reading 'id')" 解决方法 this.allMenuLabel = response.data 加 results: this.allMenuLabel = 阅读全文
posted @ 2021-12-14 18:58 Jessie橙子 阅读(3970) 评论(0) 推荐(0) 编辑
摘要: 浏览器报错现象 前端检查,查看报错信息如下 Access to XMLHttpRequest at 'http://127.0.0.1:8000/categorys/' from origin 'http://localhost:8080' has been blocked by CORS poli 阅读全文
posted @ 2021-12-14 18:28 Jessie橙子 阅读(529) 评论(0) 推荐(0) 编辑
摘要: 查不到node? 先找到安装目录 再加载下配置文件source ~/.bash_profile 参考 启动失败? 切换到前端项目 清理缓存 npm cache clean --force 切换低版本 nvm use v10 重新启动 npm run dev 启动成功 阅读全文
posted @ 2021-12-14 17:58 Jessie橙子 阅读(37) 评论(0) 推荐(0) 编辑
摘要: view新增 获取商品分类列表 class CategoryViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): """ list: 商品分类列表数据 """ # 获取全部分类 # queryset = GoodsCategory.obje 阅读全文
posted @ 2021-12-14 12:35 Jessie橙子 阅读(97) 评论(0) 推荐(0) 编辑
摘要: view文件 from rest_framework import filters class GoodsListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): queryset = Goods.objects.all() seria 阅读全文
posted @ 2021-12-11 18:33 Jessie橙子 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 创建filters.py文件 from .models import Goods from django_filters import rest_framework as filters class GoodsFilter(filters.FilterSet): """商品的过滤类""" price 阅读全文
posted @ 2021-12-11 17:57 Jessie橙子 阅读(177) 评论(0) 推荐(0) 编辑
摘要: setting中添加 INSTALLED_APPS = [ 'django_filters', ] REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'] 阅读全文
posted @ 2021-12-11 17:30 Jessie橙子 阅读(127) 评论(0) 推荐(0) 编辑
摘要: setting.py文件,添加下面设置: REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', # LimitOffsetPagination 分页风格 'PA 阅读全文
posted @ 2021-12-11 17:00 Jessie橙子 阅读(55) 评论(0) 推荐(0) 编辑
Live2D