works locally but not on heroku
So everything works great locally but when I push to heroku, my page won't load. When I do heroku logs, I get the following:
'''2013-03-02T17:29:12+00:00 heroku[router]: at=info method=GET path=/ host=blooming-waters-4509.herokuapp.com fwd="71.232.177.31" dyno=web.1 queue=0 wait=0ms connect=1ms service=10ms status=500 bytes=0''' 2013-03-02T17:29:12+00:00 app[web.1]: [02/Mar/2013 11:29:12] "GET / HTTP/1.1" 500 0
Answers
I could not see my admin styles because of an error when heroku ran collectstatic. These errors fail silently and so in my case I was not seeing any collectstatic related messages when I pushed to heroku. To troubleshoot run the following command from project root directory heroku run python manage.py collectstatic --dry-run --noinput
I got the error
OSError: [Errno 2] No such file or directory: '/app/microblog/assets'
I did have this directory locally and I thought I had committed it..but apparently git does not commit empty directories. So I created a dummy site.css in that directory. Added it to git and committed and pushed. touch bsc2/bsc2/assets/site.css git add bsc2/bsc2/assets/site.css git commit -m "created dummy site.css so heroku creates the assets directory" git push heroku master
Once I did this and checked that the 73 admin css files were indeed getting copied. I set debug back to False in base.py and added the line FilterJoe talks about in the comments below to microblog/microblog/urls.py
from django.conf import settings
urlpatterns += patterns('', (r'^static/(.*)$', 'django.views.static.serve', { 'document_root': settings.STATIC_ROOT }), )
Then I was back to having rich css admin sites with debug set to False.
refs: Thanks to this answer on stackoverflow. git with empty directories question on stackoverflow
Have the same issue here, i added '.herokuapp.com' to my allowed_hosts and that solves the 500 error. But now the static files dont work (css) for admin, however it works when debug is true.
have tried adding heroku.com and * allso but stil no success with the css files for admin when debug is false.
This same problem bothered me a lot, but I found setting DEBUG = False in the base.py file offered a temporary fix. I didn't like doing that at all but I figured the second video would add some templates or show that I was doing something wrong. I just did a google search today and found that in your base.py file, ALLOWED_HOSTS =[ ] needs to have a valid host/domain name when DEBUG is False. This is only for Django 1.5 and higher. The tutorial is done with Django 1.4. If you set ALLOWED_HOSTS = [*] this might fix the problem if you are running 1.5, but that is of course bad practice. This link should help. http://stackoverflow.com/questions/15128135/django-setting-debug-false-causes-500-error