How to install `Procfile` for Mezzanine application deployed to Heroku

I already have a Mezzanine app deployed to Heroku. The system used to work fine, but today an error message appeared on the web page Internal Server Error

. Checked with help heroku logs

and found the command is web python manage.py run_gunicorn -b 0.0.0.0:$PORT -w 1

out of date and Geroku suggests using <projName>.wsgi:application

.

But Mezzanine currently has a different project layout from Django (Mezzanine settings.py

is in the root of the project), so I tried the following in Procfile

:

web: gunicorn wsgi --log-file -

      

However, this setup results in an error message:

ImportError: No module named 'app'
...
ImportError: Could not import settings 'app.settings' (Is it on sys.path? Is there an import error in the settings file?) No module named 'app'.

      

Then I tried:

web: gunicorn <projName>.wsgi --log-file -

      

Error message (of course; -):

ImportError: No module named '<projName>'

      

So how do I install Procfile

so gunicorn can find the project settings.py

and wsgi.py

?

+3


source to share


1 answer


Content wsgi.py

:



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.wsgi import get_wsgi_application

if 'DYNO' in os.environ:     # For Heroku
    from dj_static import Cling  
    application = Cling(get_wsgi_application())
else:
    application = get_wsgi_application()

      

0


source







All Articles