It certainly works. :) Just wondering when mezzanine makes the project
folder the same level as manage.py files, instead of following the
traditional django project format.
Thanks again.
On Wednesday, March 19, 2014 1:02:58 PM UTC+8, Danny S wrote:
>
> In, your wsgi.py, you've got the following lines (which is fairly
> standard):
>
> settings_module = "%s.settings" % PROJECT_ROOT.split(os.sep)[-1]
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
>
> This will resolve to "mezzanine_test.settings"
>
> Django will try to import this.
>
> But as the error message says, "Is it on sys.path?"
>
> If you haven't set up sys.path anywhere, and you're running this from
> /within/ the mezzanine_test directory, it won't be able to find it.
> You can try two things:
> - Run the command from one directory level up, e.g.
>
> /sites/test/code$> /sites/.virtualenvs/test/bin/gunicorn -c
> mezzanine_test/gunicorn.conf.py wsgi:application
>
> Or better still: ensure that PROJECT_ROOT's parent is on the sys.path
> inside wsgi.py
>
> I have this inside mine:
> sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_ROOT, "..")))
>
> just prior to the setttings_module = line.
>
> (Note you'll have to also insert "import sys" into the file near the top)
>
> It's not exactly elegant, but it works :D
>
> Seeya. Danny.
>
>
>
> On 19 March 2014 15:20, Ziwei Zhou <[email protected] <javascript:>>
> wrote:
> > yes, i renamed from mezzanine-test to mezzanine_test, but the error is
> the
> > same.
> >
> >
> > On Wednesday, March 19, 2014 11:58:14 AM UTC+8, Danny S wrote:
> >>
> >> Did you also rename your directory?
> >>
> >> Python can't handle dashes in module names, and your directory name
> >> identifies the module as well.
> >>
> >> On 19 March 2014 13:47, Ziwei Zhou <[email protected]> wrote:
> >> > Thanks for the reply, now I got this error
> >> >
> >> > ImportError: Could not import settings 'mezzanine_test.settings' (Is
> it
> >> > on
> >> > sys.path? Is there an import error in the settings file?): No module
> >> > named
> >> > 'mezzanine_test'
> >> >
> >> >
> >> > On Wednesday, March 19, 2014 11:10:30 AM UTC+8, Stephen McDonald
> wrote:
> >> >>
> >> >> The project name needs to be a valid Python package name, which
> >> >> "mezzanine-test" isn't since you can't use dashes.
> >> >>
> >> >> Try "mezzanine_test".
> >> >>
> >> >>
> >> >> On Wed, Mar 19, 2014 at 2:04 PM, Ziwei Zhou <[email protected]>
> wrote:
> >> >>>
> >> >>> Hi
> >> >>>
> >> >>> I have my mezzanine project named as mezzanine-test and located at
> >> >>> /sites/test/code/mezzanine-test, inside mezzanine-test folder
> >> >>> following are
> >> >>> the files.
> >> >>>
> >> >>> ubuntu@test:/sites/test/code/mezzanine-test$ ls -l
> >> >>>
> >> >>> total 156
> >> >>>
> >> >>> drwxrwxr-x 3 ubuntu ubuntu 4096 Mar 17 19:27 deploy
> >> >>>
> >> >>> -rwxr-xr-x 1 ubuntu ubuntu 16192 Mar 18 17:55 fabfile.py
> >> >>>
> >> >>> -rw-r--r-- 1 ubuntu ubuntu 17819 Mar 18 17:56 fabfile.pyc
> >> >>>
> >> >>> -rw-r--r-- 1 ubuntu ubuntu 276 Mar 18 19:28 gunicorn.conf.py
> >> >>>
> >> >>> -rw-r--r-- 1 root root 6 Mar 18 19:30 gunicorn.pid
> >> >>>
> >> >>> -rwxr-xr-x 1 ubuntu ubuntu 0 Mar 16 20:18 __init__.py
> >> >>>
> >> >>> -rw-r--r-- 1 ubuntu ubuntu 134 Mar 17 18:54 __init__.pyc
> >> >>>
> >> >>> -rw-rw-r-- 1 ubuntu ubuntu 738 Mar 16 22:00 local_settings.py
> >> >>>
> >> >>> -rw-rw-r-- 1 ubuntu ubuntu 703 Mar 17 18:54 local_settings.pyc
> >> >>>
> >> >>> -rwxr-xr-x 1 ubuntu ubuntu 955 Mar 16 20:18 manage.py
> >> >>>
> >> >>> -rw-r--r-- 1 ubuntu ubuntu 1685 Mar 18 19:22 readme.md
> >> >>>
> >> >>> -rw-rw-r-- 1 ubuntu ubuntu 401 Mar 18 17:25 requirements.txt
> >> >>>
> >> >>> -rw-rw-r-- 1 ubuntu ubuntu 16146 Mar 18 18:58 settings.py
> >> >>>
> >> >>> -rw-rw-r-- 1 ubuntu ubuntu 10311 Mar 18 17:42 settings.pyc
> >> >>>
> >> >>> drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 17 19:29 static
> >> >>>
> >> >>> drwxr-xr-x 9 ubuntu ubuntu 4096 Mar 17 03:23 templates
> >> >>>
> >> >>> -rwxr-xr-x 1 ubuntu ubuntu 4567 Mar 17 22:17 urls.py
> >> >>>
> >> >>> -rw-r--r-- 1 ubuntu ubuntu 890 Mar 17 18:55 urls.pyc
> >> >>>
> >> >>> -rwxr-xr-x 1 ubuntu ubuntu 641 Mar 18 19:39 wsgi.py
> >> >>>
> >> >>> If I run following command
> >> >>>
> >> >>>
> /sites/test/code/mezzanine-test$/sites/.virtualenvs/test/bin/gunicorn
> >> >>> -c
> >> >>> gunicorn.conf.py wsgi:application
> >> >>>
> >> >>> The project will run but I got following error message when I try
> to
> >> >>> access the site.
> >> >>>
> >> >>> Traceback (most recent call last):
> >> >>>
> >> >>> File
> >> >>>
> >> >>>
> "/sites/.virtualenvs/test/lib/python3.3/site-packages/gunicorn/workers/sync.py",
>
>
> >> >>> line 136, in handle_request
> >> >>>
> >> >>> for item in respiter:
> >> >>>
> >> >>> File
> >> >>>
> >> >>>
> "/sites/.virtualenvs/test/lib/python3.3/site-packages/raven/middleware.py",
> >> >>> line 35, in __call__
> >> >>>
> >> >>> iterable = self.application(environ, start_response)
> >> >>>
> >> >>> File
> >> >>>
> >> >>>
> "/sites/.virtualenvs/test/lib/python3.3/site-packages/Django-1.6.2-py3.3.egg/django/core/handlers/wsgi.py",
>
>
> >> >>> line 187, in __call__
> >> >>>
> >> >>> self.load_middleware()
> >> >>>
> >> >>> File
> >> >>>
> >> >>>
> "/sites/.virtualenvs/test/lib/python3.3/site-packages/Django-1.6.2-py3.3.egg/django/core/handlers/base.py",
>
>
> >> >>> line 46, in load_middleware
> >> >>>
> >> >>> for middleware_path in settings.MIDDLEWARE_CLASSES:
> >> >>>
> >> >>> File
> >> >>>
> >> >>>
> "/sites/.virtualenvs/test/lib/python3.3/site-packages/Django-1.6.2-py3.3.egg/django/conf/__init__.py",
>
>
> >> >>> line 54, in __getattr__
> >> >>>
> >> >>> self._setup(name)
> >> >>>
> >> >>> File
> >> >>>
> >> >>>
> "/sites/.virtualenvs/test/lib/python3.3/site-packages/Django-1.6.2-py3.3.egg/django/conf/__init__.py",
>
>
> >> >>> line 49, in _setup
> >> >>>
> >> >>> self._wrapped = Settings(settings_module)
> >> >>>
> >> >>> File
> >> >>>
> >> >>>
> "/sites/.virtualenvs/test/lib/python3.3/site-packages/Django-1.6.2-py3.3.egg/django/conf/__init__.py",
>
>
> >> >>> line 132, in __init__
> >> >>>
> >> >>> % (self.SETTINGS_MODULE, e)
> >> >>>
> >> >>> ImportError: Could not import settings 'mezzanine-test.settings'
> (Is
> >> >>> it
> >> >>> on sys.path? Is there an import error in the settings file?): No
> >> >>> module
> >> >>> named 'mezzanine-test'
> >> >>>
> >> >>>
> >> >>> The wsgi.py file looks like following
> >> >>>
> >> >>> from __future__ import unicode_literals
> >> >>> import os
> >> >>> PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
> >> >>> settings_module = "%s.settings" % PROJECT_ROOT.split(os.sep)[-1]
> >> >>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
> >> >>> from django.core.handlers.wsgi import WSGIHandler
> >> >>> application = WSGIHandler()
> >> >>>
> >> >>>
> >> >>>
> >> >>> Any help will be greatly appreciated.
> >> >>>
> >> >>>
> >> >>> --
> >> >>> You received this message because you are subscribed to the Google
> >> >>> Groups
> >> >>> "Mezzanine Users" group.
> >> >>> To unsubscribe from this group and stop receiving emails from it,
> send
> >> >>> an
> >> >>> email to [email protected].
> >> >>>
> >> >>> For more options, visit https://groups.google.com/d/optout.
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Stephen McDonald
> >> >> http://jupo.org
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Mezzanine Users" group.
> >> > To unsubscribe from this group and stop receiving emails from it,
> send
> >> > an
> >> > email to [email protected].
> >> > For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> >>
> >> --
> >> [email protected]
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "Mezzanine Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> [email protected] <javascript:>
>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.