摘要: 前言 Django的默认缓存是存在内存当中,重启服务缓存就失效了。 文章选择用redis做缓存,需要预先安装redis数据库并启动服务 安装pip install django-redis 附带django-redis中文文档:django-redis中文文档 代码实现 在项目中的setting.p 阅读全文
posted @ 2020-09-22 19:42 吹神 阅读(315) 评论(0) 推荐(0) 编辑
摘要: 代码实现 只需要继承rest_framework.response的Response,重写self.data即可 from rest_framework.response import Response class MyResponse(Response): def __init__(self, c 阅读全文
posted @ 2020-09-22 19:17 吹神 阅读(912) 评论(0) 推荐(0) 编辑
摘要: 代码实现 在项目根目录下新建一个pagination.py文件,继承rest_framework.pagination的PageNumberPagination类 from rest_framework.pagination import PageNumberPagination class MyP 阅读全文
posted @ 2020-09-22 19:11 吹神 阅读(219) 评论(0) 推荐(0) 编辑