1.如果效果出不来,你要把dbug改成True
2.drf_yasg是swagger对于python的sdk哦
3.我的项目地址: https://gitee.com/wusen0601
1.内置的文档api 1.1 在总的urls文件里面 from django.conf.urls import url from rest_framework.documentation import include_docs_urls url(r'^doc/', include_docs_urls(title="my api title")), 1.2访问路径 127.0.0.1:8000/doc 2.swagger支持python的sdk就是drf_yasg 2.1查看是否安装 pip list|grep drf_yasg pip list|findstr drf_yasg 2.2安装 pip install drf_yasg 2.3在urls里面配置 from django.conf.urls import url from drf_yasg.views import get_schema_view from drf_yasg import openapi schema_view = get_schema_view( openapi.Info( title="Snippets API", default_version="v1", description="Test description", terms_of_service="https://www.google.com/policies/terms/", contact=openapi.Contact(email="contact@snippets.local"), license=openapi.License(name="BSD License"), ), public=True, permission_classes=[permissions.AllowAny], ) url(r'^swagger/$', schema_view.with_ui('swagger',cache_timeout=0),name='schema-swagger-ui'), url(r'^redoc/$', schema_view.with_ui('redoc',cache_timeout=0),name='schema-redoc'), 2.4在setting里面INSTALLED_APPS添加 'drf_yasg',#需要注册 2.5访问url 127.0.0.1:8000/swagger 127.0.0.1:8000/redoc
View Code
来个效果图吧