我正在尝试在我正在处理的网站中设置模块。我正在构建一个Testimonials模块,我相信我已经正确地得到了代码结构,虽然我不太确定(我是Django / Python的新手,但被告知它与RoR类似。我没有太多运气)。当我导入它并尝试引用它时,我已经遇到了Django无法识别模块模型的问题。例如:
from django.db import models
from django.db.models import permalink
但是第2行会引发错误,因为第1行不想正确导入。我从教程中获取了这些代码,我购买的书籍似乎支持这种结构。所以我做了进一步的研究,我想我需要激活我的模块才能开始在整个代码中引用它。模型模块陷入了试图加载并试图同时查看的循环中。从理论上讲,我的理解是如果我激活模块,这种情况就会停止发生。
所以我被告知我需要在终端中使用与此类似的代码:
python manage.py sql realtor/apps/testimonial/
但我的回答是:
Error: App with label realtor/apps/testimonial/ could not be found.
Are you sure your INSTALLED_APPS setting is correct?
所以我看看已安装的应用程序,据我所知......我已将其设置正确:
# project
'realtor',
'realtor.apps.blog',
'realtor.apps.testimonial',
我真的被困,因为我不知道如何向前推进,由于我缺乏经验,我甚至不知道这是我的实际问题。
谢谢你们!
更新
我还以为我会分享浏览网站时遇到的错误。
ImportError at /admin/
No module named models
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.4.1
Exception Type: ImportError
Exception Value:
No module named models
Exception Location: /Users/andrewkelly/Documents/Projects/1027_BRAD_BIRD/WORKING_BUILD/realtor/apps/testimonial/ad min.py in <module>, line 2
Python Executable: /usr/bin/python
Python Version: 2.7.2
Python Path:
['/Users/andrewkelly/Documents/Projects/1027_BRAD_BIRD/WORKING_BUILD',
'/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib- scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Library/Python/2.7/site-packages']
答案 0 :(得分:0)
realtor
是应用吗?也许您必须从INSTALLED_APPS
删除此行。