Django-Rest-Framework
简介 django-rest-framework,是一套基于Django 的 REST 框架,是一个强大灵活的构建 Web API 的工具包 官网 pip3 install djangorestframework 安装 10大特性:权限、认证、节流、版本控制、解析器、序列化、分页、视图、路由、渲染器 rest framework 主要基于CBV模式,且大部分特性是基于必须是继承了APIView;FBV模式时上述特性无法体现。 FBV/CBV参考:http://blog.aezo.cn/2018/09/24/lang/python/django.md 认证 可参看下文rest framework 源码解析【封装request和认证】。源码参考[A03_DjangoRestFrameworkTest] 自定义认证类 12345678910111213from rest_framework import exceptionsfrom rest_framework.authentication import BaseAuthenticationclass MyAuthentication(BaseAuthentication): def authenticate(self, request): token = request._request.GET.get(' ...