我正在尝试在我正在处理的站点中设置一个模块。我正在构建一个推荐模块,我相信我已经将代码结构正确地组合在一起,尽管我不太确定(我是 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']