I keep getting this error in my browser after deploying to heroku.
Internal Server Error
The server encountered an unexpected internal server error
(generated by waitress)
I ran to see if it was to do with staticfiles.
$ heroku run python manage.py collectstatic --noinput
And it came up with: OSError: [Errno 2] No such file or directory: '/app/static'
By removing the below, I was able to get passed OSError: [Errno 2] No such file or directory: '/app/static'
and it copied my static files somewhere but obviously heroku needs the below code to be there.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
I added the above back and changed the root to the below
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')`
This fixed the OSError: [Errno 2] No such file or directory: '/app/static'
error. However when running collectstatic I get this
Here is all the code used for my deployment.
0 static files copied to '/app/staticfiles', 1347 unmodified, 80 post-processed.
Which tells me no static files where copied.
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')`
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
settings_production.py
from test.settings import *
import dj_database_url
DATABASES['default'] = dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['*']
DEBUG = False
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings_production")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
Procfile
web: waitress-serve --port=$PORT test.wsgi:application
Folder structure.
test
-collection
- migrations
- static
- templates
-test
-static (contains robot.txt)
-venv
Procfile
manage.py
requirements.txt
Any help would be greatly appreciated. This has happened before on another app I am unsure what fixed it.
Thanks