“NameError: name ‘challenges’ is not defined” 变量名错误:名称 ‘challenges’ 未定义。

huangapple go评论92阅读模式
英文:

Django path('challenges/',include(challenges.urls)) NameError: name 'challenges' is not defined

问题

当我注释掉以下部分:

urlpatterns = [
   path('admin/', admin.site.urls),
   #path('challenges/',include(challenges.urls))
]

它可以正常工作,但是当我使用以下部分:

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

时,它会抛出一个错误。

在这里输入图像描述

为什么在我使用以下代码时出现错误:

urlpatterns = [
   path('admin/', admin.site.urls),
   path('challenges/',include(challenges.urls))
]
英文:

When I comment

urlpatterns = [
   path('admin/', admin.site.urls),
   #path('challenges/',include(challenges.urls))
]

it is working fine but for

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

it is throwing an error

enter image description here

why the error is occurring when I am using

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

答案1

得分: 2

"path('challenges/', include('challenges.urls'))"

英文:

you have to write like this in quotes,

path('challenges/',include("challenges.urls"))

huangapple
  • 本文由 发表于 2023年5月26日 16:13:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76338905.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定