1.reset_framework
1.1安装rest_framework
1.2使用rest_framework
在django框架中setting文件中注册rest_framework
INSTALLED_APPS = [ 'rest_framework', ]
2.reset_framework+swagger
2.1.安装drf_yasg
2.2.在django框架中setting文件中注册drf_yasg
INSTALLED_APPS = [ 'drf_yasg', ]
2.3.在setting文件中新增如下配置
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
# os.path.join(BASE_DIR, 'templates'),
# os.path.join(BASE_DIR, 'drf-yasg', 'templates'),
# os.path.join(BASE_DIR, 'templates')
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.re