简体   繁体   English

不支持在 include() 中指定命名空间而不提供 app_name

[英]Specifying a namespace in include() without providing an app_name is not supported

I am getting these error我收到这些错误

Specifying a namespace in include() without providing an app_name is not supported.不支持在不提供 app_name 的情况下在 include() 中指定命名空间。 Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.在包含的模块中设置 app_name 属性,或者传递一个包含模式列表和 app_name 的 2 元组。

my code is shown below我的代码如下所示

projectname.urls项目名称.urls

from django.contrib import admin
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include('learning.urls',namespace='learning')),
  ]

app_name.urls app_name.urls

from django.urls import path
from learning.views import SendEmail

urlpatterns = [
   path('',SendEmail.as_view(),name='home')
]

Try this solution:试试这个解决方案:

from django.urls import path
from learning.views import SendEmail

app_name = "learning"

urlpatterns = [
    path('',SendEmail.as_view(),name='home')
]

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

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