我正在开发一个项目中的应用程序,安装了夹层CMS框架的姜戈在https://github.com/stephenmcd/mezzanine中可用。
我想引用如下所示的博客模型
from mezzanine.blog.models import BlogPost, BlogCategory在原始源代码中,但我收到一条错误消息,指出mezzanine和BlogPost, BlogCategory一样都是一个未解析的引用
我尝试了几种方法,比如
from newsletter.mezzanine.blog.models import BlogPost, BlogCategory我在哪里得到了错误消息
File "/Users/jorgezavala/PycharmProjects/mezzanine/newsletter/newsletter/campaign/urls.py", line 4, in <module>
from newsletter.mezzanine.blog.models import BlogPost, BlogCategory
ImportError: No module named mezzanine.blog.models以这种方式使用python shell
(mezzanine)Jorges-MacBook-Air-2:newsletter jorgezavala$ python manage.py shell
Python 2.7.10 (default, Jul 30 2016, 18:31:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from mezzanine.blog.models import BlogPost, BlogCategory
>>>
>>> print BlogPost.objects.get(id = 1 )
The future of works
>>> print BlogPost.objects.get(id = 2 )
Where learning go to work我验证mezzanine是否已安装并正常工作。问题是我什么时候想把它作为一个应用程序来运行。
我不知道如何使引用能够访问我使用mezzanine创建的帖子中的可用信息,这些信息将由同一项目中的独立应用程序处理。
任何帮助我们都将不胜感激。
发布于 2016-12-18 17:39:53
这是一次很好的学习经历,解决了我关于未解决的参考文献的问题。
这与PyCharm中的配置有关。我有错误的虚拟环境设置,当我查看PyCharm help https://www.jetbrains.com/help/pycharm/2016.1/project-interpreter.html#d175278e163中的参考时发现了它
一旦我选择了正确的环境变量,环境变量就会被导出、更正,一切都会正常工作
https://stackoverflow.com/questions/41195346
复制相似问题