[英]Not able to reference models from django import
我正在尝试在我正在处理的站点内设置模块。 我正在构建一个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']
realtor
是一个应用程序吗? 也许您必须从INSTALLED_APPS
删除此行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.