DRF框架的安装配置及特点介绍
DRF框架的安装配置及特点介绍
安装
pip install djangorestframework
配置
1)在settings中注册
INSTALLED_APPS = [
# ...
'rest_framework',
]
2)在settings中自定义drf配置
注:drf配置查找顺序,自定义settings的REST_FRAMEWORK配置字典 => drf默认settings的DEFAULTS
REST_FRAMEWORK = {}
特点
drf的封装特点:特定功能在特定模块下 from rest_framework.views import APIView from rest_framework.response import Response from rest_framework.request import Request from rest_framework.exceptions import APIException from rest_framework.filters import OrderingFilter from rest_framework.pagination import PageNumberPagination from rest_framework.settings import APISettings
settings中注册配图: