Reputation: 75
I know that this questions has been asked numerous times but after going through pretty much every thread I could find, I am still struggling to make sense of my problem. I have a django project on heroku which works perfectly fine as long as I set the setting variable debug=True. https://dry-depths-69493.herokuapp.com/
However, once I have set it to False, I get a 500 error. I have checked the settings.py which has:
ALLOWED_HOSTS = ['dry-depths-69493.herokuapp.com','127.0.0.1',"localhost", "0.0.0.0", ".herokuapp.com"]
I have set unset all unnecessary env variables in Django and only added
COLLECTSTATIC: 1
And I also have included Whitenoise and added dj_database_url. Does anyone have another idea, what could be the reason for these issues? Unfortunately the logs just say that it is a 500 error but give no specifics. Here is the github-link: https://github.com/Datenrausch/heroku
Upvotes: 0
Views: 1924
Reputation: 75
This seems to be a WhiteNoise X Heroku problem. I fixed the issue by using the approach of this post:
Django Debug=False whitenoise not working
Crucial thing seems to be this part in settings.py:
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
Upvotes: 0
Reputation: 11
To have more debug information, I would login into the heroku dyno using heroku-cli and the command heroku run bash
and then run Django webserver with ./manage.py runserver
. This way you should already see if there is something wrong.
If it works normally, then run it on the background (./manage.py runserver &
) and try to access the homepage with wget localhost:8000
. At this point you should have the 500 error debug information.
Upvotes: 1