Who I can reference the blog model of mezzanine in a Django and python project

211 views Asked by At

I am developing an app in a project that has installed the Mezzanine CMS framework for Django available in https://github.com/stephenmcd/mezzanine.

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

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

(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

1

There are 1 answers

0
Jorge Zavala On

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. 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

Once I choose the right one the environment variables was exported corrected and everything working correctly