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

Sorry You must be a logged in, registered user to answer a question.

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

Sorry didnt know how to edit this comment..some of my code markdowns are not showing up
Hari Jayaram on

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.

Sorry this wasn't ment as an answer it was suppose to be a comment.
Azazel666 on

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

I got it to work and it was my fault. It turns out the collectstatic was failing silently on heroku. To debug the collectstatic on heroku run "heroku run python manage.py collectstatic --dry-run --noinput". In my case it informed me that "OSError: [Errno 2] No such file or directory: '/app/microblog/assets'"
Hari Jayaram on
I cannot get the admin to look fine with Debug= False despite the Setings that Filter Joe talks about on Heroku, I tried with Django 1.5.1 and with 1.4.3
Hari Jayaram on
If you're still finding that static files don't work (CSS for admin), then you probably didn't yet put the extra lines needed in urls.py as described at the end of lesson 2: from django.conf import settings at top, then at bottom: urlpatterns += patterns('', (r'^static/(.*)$', 'django.views.static.serve', { 'document_root': settings.STATIC_ROOT }), )
FilterJoe on
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.
Azazel666 on
Yeah, unfortunately these videos are being made at a time when Django is moving pretty quickly (I expect that to slow down now that 1.5 is out and we haven't had any major security exploits in Rails/PHP lately). To keep your codebase as close to the videos as possible, install Django with `pip install django==1.4.3`. Or add `ALLOWED_HOSTS = ['<your heroku domain>']` to `settings/base.py`
kennethlove (Staff) on
Thanks. It's unlucky that these were videos were created days before django 1.5 came out. Would putting heroku.com in ALLOWED_HOSTS work?
Brian Yee on