Python NameError:未定义名称“包含”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34471102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python NameError: name 'include' is not defined
提问by eloiletagant
I'm currently developing a website with the framework django (I'm very beginner) but I have a problem with python : since I have created my templates, I can't run server anymore for this reason (Stacktrace points to a line in urls.py):
我目前正在使用框架 django 开发一个网站(我是初学者),但我在使用 python 时遇到了问题:由于我已经创建了模板,因此我无法再运行服务器(Stacktrace 指向中的一行) urls.py):
<stacktrace>
...
path('apppath/', include('myapp.urls')),
NameError: name 'include' is not defined
Where can I import include
from?
我可以include
从哪里进口?
采纳答案by Rahul Gupta
Guessing on the basis of whatever little information provided in the question, i think you might have forget to add the following import in your urls.py
file.
根据问题中提供的任何小信息进行猜测,我认为您可能忘记在urls.py
文件中添加以下导入。
from django.conf.urls import include