majid majid - 1 month ago 10
Python Question

heroku does not support django app and raise the error

According to the this post from heroku, I launch raw django successfull , but when I create app(not project ) and push to heruku , I have a error and their logs show this :

2015-12-20T18:49:26.369707+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2015-12-20T18:49:26.369708+00:00 app[web.1]: __import__(module)
2015-12-20T18:49:26.369708+00:00 app[web.1]: File "/app/hellodjango/wsgi.py", line 16, in <module>
2015-12-20T18:49:26.369709+00:00 app[web.1]: application = get_wsgi_application()
2015-12-20T18:49:26.369710+00:00 app[web.1]: django.setup()
2015-12-20T18:49:26.369710+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2015-12-20T18:49:26.369711+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
2015-12-20T18:49:26.369711+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2015-12-20T18:49:26.369712+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
2015-12-20T18:49:26.369713+00:00 app[web.1]: app_config = AppConfig.create(entry)
2015-12-20T18:49:26.369714+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
2015-12-20T18:49:26.369714+00:00 app[web.1]: module = import_module(entry)
2015-12-20T18:49:26.369715+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
2015-12-20T18:49:26.369716+00:00 app[web.1]: __import__(name)
2015-12-20T18:49:26.369717+00:00 app[web.1]: ImportError: No module named news
2015-12-20T18:49:26.370386+00:00 app[web.1]: [2015-12-20 18:49:26 +0000] [9] [INFO] Worker exiting (pid: 9)
2015-12-20T18:49:26.482215+00:00 app[web.1]: [2015-12-20 18:49:26 +0000] [12] [ERROR] Exception in worker process:
2015-12-20T18:49:26.482219+00:00 app[web.1]: Traceback (most recent call last):
2015-12-20T18:49:26.482220+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
2015-12-20T18:49:26.482221+00:00 app[web.1]: worker.init_process()
2015-12-20T18:49:26.482222+00:00 app[web.1]: self.load_wsgi()
2015-12-20T18:49:26.482221+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
2015-12-20T18:49:26.482222+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
2015-12-20T18:49:26.482223+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2015-12-20T18:49:26.482224+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-12-20T18:49:26.482225+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-12-20T18:49:26.482226+00:00 app[web.1]: return self.load_wsgiapp()
2015-12-20T18:49:26.482227+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-12-20T18:49:26.482227+00:00 app[web.1]: return util.import_app(self.app_uri)
2015-12-20T18:49:26.482224+00:00 app[web.1]: self.callable = self.load()
2015-12-20T18:49:26.482228+00:00 app[web.1]: __import__(module)
2015-12-20T18:49:26.482228+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2015-12-20T18:49:26.482229+00:00 app[web.1]: File "/app/hellodjango/wsgi.py", line 16, in <module>
2015-12-20T18:49:26.482231+00:00 app[web.1]: django.setup()
2015-12-20T18:49:26.482232+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
2015-12-20T18:49:26.482230+00:00 app[web.1]: application = get_wsgi_application()
2015-12-20T18:49:26.482230+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2015-12-20T18:49:26.482233+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
2015-12-20T18:49:26.482232+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2015-12-20T18:49:26.482244+00:00 app[web.1]: app_config = AppConfig.create(entry)
2015-12-20T18:49:26.482244+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
2015-12-20T18:49:26.482245+00:00 app[web.1]: module = import_module(entry)
2015-12-20T18:49:26.482246+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
2015-12-20T18:49:26.482246+00:00 app[web.1]: __import__(name)
2015-12-20T18:49:26.482246+00:00 app[web.1]: ImportError: No module named news
2015-12-20T18:49:26.482247+00:00 app[web.1]: Traceback (most recent call last):
2015-12-20T18:49:26.482248+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
2015-12-20T18:49:26.482248+00:00 app[web.1]: worker.init_process()
2015-12-20T18:49:26.482249+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
2015-12-20T18:49:26.482249+00:00 app[web.1]: self.load_wsgi()
2015-12-20T18:49:26.482250+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
2015-12-20T18:49:26.482250+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2015-12-20T18:49:26.482251+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2015-12-20T18:49:26.482251+00:00 app[web.1]: self.callable = self.load()
2015-12-20T18:49:26.482252+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2015-12-20T18:49:26.482252+00:00 app[web.1]: return self.load_wsgiapp()
2015-12-20T18:49:26.482253+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2015-12-20T18:49:26.482254+00:00 app[web.1]: return util.import_app(self.app_uri)
2015-12-20T18:49:26.482254+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
2015-12-20T18:49:26.482255+00:00 app[web.1]: __import__(module)
2015-12-20T18:49:26.482255+00:00 app[web.1]: File "/app/hellodjango/wsgi.py", line 16, in <module>
2015-12-20T18:49:26.482256+00:00 app[web.1]: application = get_wsgi_application()
2015-12-20T18:49:26.482257+00:00 app[web.1]: django.setup()
2015-12-20T18:49:26.482256+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2015-12-20T18:49:26.482258+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
2015-12-20T18:49:26.482258+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2015-12-20T18:49:26.482259+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
2015-12-20T18:49:26.482259+00:00 app[web.1]: app_config = AppConfig.create(entry)
2015-12-20T18:49:26.482260+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
2015-12-20T18:49:26.482260+00:00 app[web.1]: module = import_module(entry)
2015-12-20T18:49:26.482261+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
2015-12-20T18:49:26.482262+00:00 app[web.1]: __import__(name)
2015-12-20T18:49:26.482262+00:00 app[web.1]: ImportError: No module named news
2015-12-20T18:49:26.482269+00:00 app[web.1]: [2015-12-20 18:49:26 +0000] [12] [INFO] Worker exiting (pid: 12)
2015-12-20T18:49:26.498024+00:00 app[web.1]: Traceback (most recent call last):
2015-12-20T18:49:26.498027+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2015-12-20T18:49:26.498068+00:00 app[web.1]: sys.exit(run())
2015-12-20T18:49:26.498088+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2015-12-20T18:49:26.498129+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2015-12-20T18:49:26.498133+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 192, in run
2015-12-20T18:49:26.498190+00:00 app[web.1]: super(Application, self).run()
2015-12-20T18:49:26.498192+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2015-12-20T18:49:26.498236+00:00 app[web.1]: Arbiter(self).run()
2015-12-20T18:49:26.498237+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 206, in run
2015-12-20T18:49:26.498293+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2015-12-20T18:49:26.498360+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 347, in stop
2015-12-20T18:49:26.498295+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 302, in halt
2015-12-20T18:49:26.498359+00:00 app[web.1]: self.stop()
2015-12-20T18:49:26.498429+00:00 app[web.1]: time.sleep(0.1)
2015-12-20T18:49:26.498430+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 219, in handle_chld
2015-12-20T18:49:26.498573+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2015-12-20T18:49:26.498489+00:00 app[web.1]: self.reap_workers()
2015-12-20T18:49:26.498491+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 464, in reap_workers
2015-12-20T18:49:26.498621+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2015-12-20T18:49:27.233547+00:00 heroku[web.1]: State changed from starting to crashed
2015-12-20T18:49:27.222200+00:00 heroku[web.1]: Process exited with status 1
2015-12-20T18:49:19.961319+00:00 heroku[web.1]: State changed from starting to crashed
2015-12-20T18:49:19.962476+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-20T18:49:43.551736+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=h45.herokuapp.com request_id=f58bb9b7-26a2-4a1f-ad34-da0411ef2dec fwd="109.169.49.170" dyno= connect= service= status=503 bytes=
2015-12-20T18:49:44.162458+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=h45.herokuapp.com request_id=76ce8d1a-b9a9-494d-9530-900159c99639 fwd="109.169.49.170" dyno= connect= service= status=503 bytes=
2015-12-20T18:49:44.405774+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=h45.herokuapp.com request_id=8507a120-4ba8-4c02-96a6-3284266e202a fwd="109.169.49.170" dyno= connect= service= status=503 bytes=


i have a app with
news
name and in the news app i have a one directory where images from admin save on that with
img
name

this is my
Procfile
:

web: gunicorn hellodjango.wsgi --log-file -


and this is my
wsgi
:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hellodjango.settings")

application = get_wsgi_application()


from django.core.wsgi import get_wsgi_application
from dj_static import Cling

application = Cling(get_wsgi_application())

Answer

i think this error show , because your project structure is wrong ,please Comparison between the your structure and this structure :

myapp
 |_my_app
 | |_Settingd.py
 | |_urls.py
 | |_wsgi.py
 |__webapp
 |   |_statics(folder) 
 |   |_admin.py
 |   |_models.py
 |   |_views.py
 |__manage.py
 |__requirements.txt
 |__Procfile