摘要: #1.查询所有用户 http://192.168.56.100:8888/user/user/ #2.查询id=1的用户 http://192.168.56.100:8888/user/user/1/ #3.查询 用户名(tom),激活的用户 http://192.168.56.100:8888/u 阅读全文
posted @ 2020-10-27 21:51 yujian8759 阅读(89) 评论(0) 推荐(0) 编辑
摘要: from django.http import HttpResponse from django_filters.rest_framework import DjangoFilterBackend from rest_framework import viewsets from rest_frame 阅读全文
posted @ 2020-10-27 21:50 yujian8759 阅读(117) 评论(0) 推荐(0) 编辑
摘要: user/urls.py ModelViewSet注册路由三部曲 from django.urls import include, path from user import views from rest_framework.routers import SimpleRouter, Default 阅读全文
posted @ 2020-10-27 21:20 yujian8759 阅读(93) 评论(0) 推荐(0) 编辑
摘要: # 过滤器 # 1,安装 django-filter # 2,注册应用 # 3,配置settings, 在view里配置可过滤的字段 # 4,使用 查询字符串携带过滤信息 REST_FRAMEWORK = { # 文档报错: AttributeError: ‘AutoSchema’ object h 阅读全文
posted @ 2020-10-27 20:56 yujian8759 阅读(97) 评论(0) 推荐(0) 编辑
摘要: pip install djangorestframework==3.11.1 pip install django-filter==2.3.0 # 过滤器 pip install markdown 在syl/settings.py中注册 INSTALLED_APPS = [ 'django_fil 阅读全文
posted @ 2020-10-27 20:29 yujian8759 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1.认证(用户登录校验用户名密码或者token是否合法) 2.权限(根据不同的用户角色,可以操作不同的表) 3.限流(限制接口访问速度) 4.序列化(返回json) 5.分页 6.版本(接口版本号,用 v1/v2/v3) # api.example.com/v1/login # 只有用户名密码登录 阅读全文
posted @ 2020-10-27 20:27 yujian8759 阅读(71) 评论(0) 推荐(0) 编辑