簡體   English   中英

drf_yasg AttributeError: 'function' 對象沒有屬性 'with_ui'

[英]drf_yasg AttributeError: 'function' object has no attribute 'with_ui'

嘗試根據他們的文檔使用drf_yasg記錄 API,但我收到此錯誤“AttributeError: 'function' object has no attribute 'with_ui'”這是我在urls.py 中的代碼

schema_view = get_schema_view(
    openapi.Info(
        title="Blog API",
        default_version='v1',
        description="A sample API for learning DRF",
        terms_of_service="https://www.google.com/policies/terms/",
        contact=openapi.Contact(email="riajulkashem@gmail.com"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(permissions.AllowAny,),
)

urlpatterns = [
    path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]

檢查您正在導入的庫,它from drf_yasg.views import get_schema_view

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM