Trying to documenting API using drf_yasg according to their documentation but I got this error "AttributeError: 'function' object has no attribute 'with_ui'" here is my code in 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.