本文介绍了如何禁用"Django登录"尝试在浏览器中访问swagger api时进入页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当尝试访问生成的swagger文档时,我得到的空白页仅带有"Django登录"链接.我正在使用drf_yasg库来渲染swagger文档.
I am getting a blank page with just a "Django Login" link when trying to access generated swagger docs. I am using drf_yasg library to render swagger documentation.
生成swagger文档的代码类似于swagger文档中提到的代码.
Code to generate swagger docs is similar to mentioned in swagger docs.
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,),
)
推荐答案
您需要根据
You will need to add the following to your settings.py
per the docs
SWAGGER_SETTINGS = {
'USE_SESSION_AUTH': False
}
这篇关于如何禁用"Django登录"尝试在浏览器中访问swagger api时进入页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!