I had a similar problem and it's hard to figure out when DEBUG is set to False. When I reconfigured it back to DEBUG = True
everything worked fine again. So the problem was
You don't generally see this error in development because when DEBUG = True
, ManifestStaticFilesStorage switches to non-hashed urls.
https://stackoverflow.com/a/51060143/7986808
The solution to the problem in your case may differ from mine. But you can find the problem by changing the logging method of your Django project, so you can see more info in the command line when running heroku logs -t -a <heroku-app>
even in DEBUG = False
mode.
Change your django logging settings in settings.py
as follow:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': ('%(asctime)s [%(process)d] [%(levelname)s] '
'pathname=%(pathname)s lineno=%(lineno)s '
'funcname=%(funcName)s %(message)s'),
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'simple': {
'format': '%(levelname)s %(message)s'
}
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'django': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
'django.request': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
}
}
Then run heroku logs -t -a <heroku-app>
and open the url where you previously got 500 Error you will find out the problem in logs. Hope this will help you.
In case there are some static files missing just switch your static root in settings.py
as follow STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
. Running heroku run python manage.py collectstatic -a <heroku-app>
creates staticfiles directory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…