16👍
The problem is the absolute path you are using for STATIC_ROOT
isn’t found in Heroku server.
To resolve it, consider the following approach.
In your settings.py:
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT= os.path.join(PROJECT_DIR,'staticfiles/')
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT,'static/'),
)
3👍
You’re on your way. What’s happening is that Heroku is trying to use your STATICFILES_DIRS setting (/home/kevin/web/django/appheroku/blogapp/static) that exists locally on your machine but won’t doesn’t exist on the Heroku server.
A simple solution is to remove that line from the staticfiles_dir variable so you have:
STATICFILES_DIRS = ()
Then your default STATICFILES_FINDERS will kick in and you should be good to go to run your app both locally as well as deployed on Heroku.
- How can I rename a column label in Django Admin for a field that is a method//property?
- How to write a Django view for a POST request
1👍
For anyone who’s coming in like me:
Like @eliotk implies,
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT= os.path.join(PROJECT_DIR,'staticfiles/')
STATICFILES_DIRS = ()
This is the config you want to avoid FileNotFoundError: [Errno 2] No such file or directory:
errors or OSError: [Errno 30] Read-only file system:
errors.