When I run python manage.py collectstatic --noinput in my local machine, it works fine. But when heroku runs python manage.py collectstatic --noinput it gives error like this: for entry in os.scandir(path) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_5d05d870/static'
My project directory seems like this:
mysite-----|libooki(app)----------|migrations
|----------------------|init.py
|----------------------|admin.py
|----------------------|........
-----------|media
-----------|media_cdn
-----------|mysite
-----------|static|--------------|css|------style.css
-----------|staticfiles
-----------|templates
-----------|.........
My settings.py seems like this. (I followed this article: https://devcenter.heroku.com/articles/django-assets)
from pathlib import Path
import os
import django_heroku
BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
INSTALLED_APPS = [
........,
'libooki',
]
MIDDLEWARE = [
...........................................,
'whitenoise.middleware.WhiteNoiseMiddleware',
]
WSGI_APPLICATION = 'mysite.wsgi.application'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
MEDIA_ROOT = os.path.join(BASE_DIR,'media_cdn')
MEDIA_URL = '/media/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
django_heroku.settings(locals())