3

I already have a Mezzanine app deployed on Heroku. The system ran OK before, but today the web page showed an error message Internal Server Error. Checked with heroku logs and found that the command web python manage.py run_gunicorn -b 0.0.0.0:$PORT -w 1 is deprecated and Heroku suggests using <projName>.wsgi:application.

But Mezzanine currently has different project layout from Django (Mezzanine's settings.py is in the project root directory), so I tried the following in Procfile:

web: gunicorn wsgi --log-file -

However, such a setting results in 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 -

The error message (of course ;-):

ImportError: No module named '<projName>'

So, how do I set Procfile so that gunicorn is able to find the project's settings.py and wsgi.py?

Randy Tang
  • 4,283
  • 12
  • 54
  • 112
  • 1
    Good question ... May be the question should be `How to define Procfile when wsgi.py file also in same folder?`. Some try i end up with `web: gunicorn --pythonpath="$PWD/myproject" wsgi:application --log-file=-` but really it's not working though .. – Raja Simon Jun 17 '15 at 13:05
  • Can you please display your `wsgi.py`? IIRC this has something to do with there needing to be some kind of agreement between how the Procfile line specifies the wsgi call and how settings is called in `wsgi.py`. – Two-Bit Alchemist Jun 17 '15 at 15:47
  • I have to put the wsgi.py in the Answer for better examining. – Randy Tang Jun 17 '15 at 16:12
  • It turned out that Mezzanine is about to roll out a new version which has the same project layout as Django's and it's already available. Check https://github.com/stephenmcd/mezzanine/issues/1250#issuecomment-112803085. So, my problem is sort of solved if I use the new Mezzanine. Others using old Mezzanine may still need a solution? – Randy Tang Jun 18 '15 at 07:45

0 Answers0