Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django REST框架&x2B;Django休息大摇大摆_Python_Django_Django Rest Framework_Swagger_Django Swagger - Fatal编程技术网

Python Django REST框架&x2B;Django休息大摇大摆

Python Django REST框架&x2B;Django休息大摇大摆,python,django,django-rest-framework,swagger,django-swagger,Python,Django,Django Rest Framework,Swagger,Django Swagger,在配置Swagger UI时遇到了困难,这里是-,中非常有说明性的文档。我的settings.py看起来像这样 url.py看起来像这样 但是招摇过市的网页没有正确加载 控制台日志如下所示 这里可能有什么问题?看一看,这里有一些代码示例,介绍如何将其与DRF联系起来。通过访问文档,您可以了解更多关于这方面的信息 如果您只想启动并运行,而不想了解更多关于该库的信息,那么在显示项目体系结构和将DRS与DRF集成方面,这是一项很好的工作。首先,将django rest framework安装到

在配置Swagger UI时遇到了困难,这里是-,中非常有说明性的文档。我的settings.py看起来像这样

url.py看起来像这样

但是招摇过市的网页没有正确加载

控制台日志如下所示

这里可能有什么问题?

看一看,这里有一些代码示例,介绍如何将其与DRF联系起来。通过访问文档,您可以了解更多关于这方面的信息


如果您只想启动并运行,而不想了解更多关于该库的信息,那么在显示项目体系结构和将DRS与DRF集成方面,这是一项很好的工作。

首先,将django rest framework安装到您的应用程序中,并将其导入setting.py文件中

SWAGGER_SETTINGS = {
   'SECURITY_DEFINITIONS': {
    'api_key': {
        'type': 'apiKey',
        'in': 'header',
        'name': 'Authorization'
    }
},  # setting to pass token in header
'USE_SESSION_AUTH': False,
# set to True if session based authentication needed
'JSON_EDITOR': True,
'api_path': 'api/',
'api_version': 'v0',

"is_authenticated": False,  # Set to True to enforce user authentication,
"is_superuser": False,  # Set to True to enforce admin only access
'unauthenticated_user': 'django.contrib.auth.models.AnonymousUser',
# unauthenticated user will be shown as Anonymous user in swagger UI.
使用DRF制作一些API,然后在setting.py文件中添加swagger设置

SWAGGER_SETTINGS = {
   'SECURITY_DEFINITIONS': {
    'api_key': {
        'type': 'apiKey',
        'in': 'header',
        'name': 'Authorization'
    }
},  # setting to pass token in header
'USE_SESSION_AUTH': False,
# set to True if session based authentication needed
'JSON_EDITOR': True,
'api_path': 'api/',
'api_version': 'v0',

"is_authenticated": False,  # Set to True to enforce user authentication,
"is_superuser": False,  # Set to True to enforce admin only access
'unauthenticated_user': 'django.contrib.auth.models.AnonymousUser',
# unauthenticated user will be shown as Anonymous user in swagger UI.
}


注意:-您可以根据需要编辑招摇过市设置。

您甚至没有在
安装的应用程序中安装rest\u框架。