[Python] DjangoはAPIドキュメントを生成します

  1. グローバル構成
# DRF 全局配置
REST_FRAMEWORK = {
    
    
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}

  1. 合計ルーティングファイルurls.py
from rest_framework.documentation import include_docs_urls


urlpatterns = [
    path('docs/', include_docs_urls(title="DRF API 文档", description="描述信息")),
]
  1. ブラウザはlocalhost:8000 / docsにアクセスします

おすすめ

転載: blog.csdn.net/qq_22227087/article/details/109031898