[英]Who I can reference the blog model of mezzanine in a Django and python project
I am developing an app in a project that has installed the Mezzanine CMS framework for Django available in https://github.com/stephenmcd/mezzanine . 我正在一个项目中开发一个应用程序,该项目已经安装了https://github.com/stephenmcd/mezzanine中提供的Django Mezzanine CMS框架。
I would like to reference the blog model that is shown as 我想引用显示为的博客模型
from mezzanine.blog.models import BlogPost, BlogCategory
in the original source code, but I am getting an error message that says that mezzanine
is an unresolved reference as well as BlogPost, BlogCategory
在原始的源代码中,但是我收到一条错误消息,指出
mezzanine
是一个未解决的引用,以及BlogPost, BlogCategory
I tried several ways to do it like 我尝试了几种方法来做到这一点
from newsletter.mezzanine.blog.models import BlogPost, BlogCategory
where I get the error message 我在哪里得到错误信息
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
Using python shell in this way 以这种方式使用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
I validate that mezzanine is installed and working. 我确认夹层已安装并正常工作。 The issue is when I want to run it as an app.
问题是当我想将其作为应用程序运行时。
I do not have a clue how to make the references to be able to access the information available in the posts that I created with mezzanine to be processed by an independent application within the same project. 我不知道如何使引用能够访问由夹层创建的帖子中的可用信息,这些帖子将由同一项目中的独立应用程序处理。
Any help will be very much appreciated 任何帮助将不胜感激
It has been a great learning experience to solve the issue that I had about unresolved reference. 解决我遇到的有关未解决参考的问题是非常不错的学习经验。
It was related to the configuration in PyCharm. 它与PyCharm中的配置有关。 I had the wrong virtual environment setting, I found it when i reviewed the reference in the PyCharm help https://www.jetbrains.com/help/pycharm/2016.1/project-interpreter.html#d175278e163
我使用了错误的虚拟环境设置,当我在PyCharm帮助https://www.jetbrains.com/help/pycharm/2016.1/project-interpreter.html#d175278e163查阅参考资料时发现了它
Once I choose the right one the environment variables was exported corrected and everything working correctly 一旦选择了正确的环境变量,就可以更正环境变量,并且一切正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.