简体   繁体   English

谁能帮助我,为什么我得到的食物没有定义错误? 我附上了 Django 模块的结构

[英]can anyone help me, why I am getting food is not defined error ? I have attached the structure of Django module

在此处输入图片说明

I have added food app.我添加了食物应用程序。 inside food app i added url.py.在食品应用程序中,我添加了 url.py。 TO import food.url.py i used include method to import food.url.py in mysite.url.py.要导入 food.url.py,我使用了包括在 mysite.url.py 中导入 food.url.py 的方法。 but while running the server i am getting error as food is not defined但是在运行服务器时我收到错误,因为食物没有定义

Pass argument in strings of include function like need not be import your apps在包含函数的字符串中传递参数,例如不需要导入您的应用程序

urlpatterns = [
path('admin/', admin.site.urls), 
path('', include('food.urls')), #change in this line 
]

In this URLs pattern pass argument in include method as string like include ('food.urls')在此 URL 模式中,将 include 方法中的参数作为字符串传递,如 include ('food.urls')

In this file not need the import a food apps but see the your import statment syntax is wrong if you use this way python interpreter will find __init__.py file in module so create please refer documention of python module or see the following enter link description here在此文件中不需要导入食品应用程序,但如果您使用这种方式,请查看您的导入语句语法错误 python 解释器将在模块中找到__init__.py文件,因此创建请参阅 python 模块的文档或在此处查看以下输入链接描述

you does not require to add from mysite import food您不需要添加from mysite import food

just add path('', include('food.urls') where food.urls in single quotation只需在单引号中添加path('', include('food.urls') where food.urls

Make sure food app added in your INSTALLED_APPS list in settings.py确保将food应用添加到settings.py INSTALLED_APPS列表中

In above file first of all you don't need to add from mysite import food And in your url_patterns the second urls is giving like this:首先在上面的文件中,您不需要添加from mysite import food并且在您的 url_patterns 中,第二个网址是这样的:

 path('',include('food.urls'))

just add one single quotes..只需添加一个单引号..

暂无
暂无

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

相关问题 错误消息:为什么我在 Django 的 views.py 中添加了 get() 却得到“无”? 谁能帮我 - Error Message: why i am getting "None" although i have add get() at views.py in Django ??? Can anyone help me 为什么我收到 OmegaExpansion header 的 Python 模块错误。 谁能帮我? - why am i getting Python Module error for OmegaExpansion header. Can anyone help me? 谁能帮我解决运行这个tensorflow程序时遇到的错误 - can anyone help me in resolving the error which I am getting while running this tensorflow program 我在 python 的 if -else 程序中遇到编译错误。代码是用 Python 3 编写的,谁能帮帮我 - I am getting compilation error in if -else program in python .The code is written in Python 3, can anyone help me 谁能告诉我为什么我在 flask 中收到“NameError: name 'validators' is not defined”? 因为我是 flask 的新手 - Can anyone tell me why i am getting “NameError: name 'validators' is not defined” in flask? As i am new to flask 我在pygame中创建移动平台时遇到了麻烦。 我遇到错误,有人可以帮我吗? - I am having trouble creating moving platforms in pygames. I am getting an error, can anyone help me out please? 嗨,我有一个 python 脚本可以使用 openpyxl 处理 excel 数据,但是在 2500 行之后我收到 Memory 错误。 谁可以帮我这个事? - Hi, I have a python script to work with excel data using openpyxl ,but after 2500 rows i am getting Memory Error. Can anyone help me on this? 谁能帮我理解为什么我有错误“列表索引超出范围”? - Can anyone help me to understand why i have the error “list index out of range”? 列的长度必须与键相同。 为什么我会收到这样的错误? 谁能帮我吗? - Columns must be same length as key. Why I'm getting such error? can anyone help me out? 当我运行heroku ps:scale web = 1命令时,出现此错误。 谁能帮我这个 - When i run heroku ps:scale web=1 command i am getting this error. Can anyone help me with this
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM