【发布时间】:2023-03-07 20:44:01
【问题描述】:
我按照官方 django-oauth 工具包文档 (https://django-oauth-toolkit.readthedocs.io/en/latest/tutorial/tutorial_02.html) 的说明,手动包含了所有 oauth-toolkit url,以防止用户创建应用程序。
在我的根 urls.py 中,我在 url 模式中添加了以下行,如教程中所示:
url(r'^o/', include(oauth2_endpoint_views, namespace="oauth2_provider")),
我使用了来自django.conf.url 包的include。
现在当我启动服务器时,它说
“不支持在 include() 中指定命名空间而不提供 app_name。在包含的模块中设置 app_name 属性,或者传递包含模式列表和 app_name 的 2 元组。”
当我像这样向 url 命令添加 name 属性时:
url(r'^o/', include(oauth2_endpoint_views, namespace="oauth2_provider"), name="oauth2_provider"),
服务器启动,但当我尝试访问“localhost/o/applications”时,它显示“NoReverseMatch: 'oauth2_provider' 不是注册的命名空间”
我做错了什么?
【问题讨论】:
-
@ishitasharma 我到底应该在哪里做呢? oauth2_endpoint_views 只是我想要提供的所有 oauth2_provider 路由的数组...
-
尝试使用这个答案
标签: django django-oauth