繁体   English   中英

drf-yasg Django restframework Swagger 页面返回空白页 django 登录 href 链接

[英]drf-yasg Django restframework Swagger Page return blank page with django login a href link

您好我尝试添加到我的项目 swagger 但它返回 401 错误,请帮助我解决这个问题

这是我的路由器

from . import router
    schema_view = get_schema_view(
        openapi.Info(
            title='EduOn API',
            description="EduOn API",
            default_version='v1',
            terms_of_service='https://www.google.com/policies/terms/',
            contact=openapi.Contact(email="algoritmgateway@gmail.com"),
            license=openapi.License(name='EduOn License'),
        ),
        public=True,
        permission_classes=(permissions.AllowAny,)
    )

注册我的路由器:

urlpatterns += router.router.urls

在列表中的 urlpatterns 中:

#documents
    url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
    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'),

并在 INSTALLED_APPS 中注册

我在 onluy localhist:8000 中得到我的 expecct output 但如果我重新启动 nginx 并进入生产网站,它会得到这个 output(在此处输入图像描述

我遇到了同样的问题。 如果您之前收集了 static 个文件,则需要为 swagger ui 再次收集 static 个文件。

python manage.py collectstatic

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM