I've been workingon my app making multiple pushes to deploy on heroku and everything was fine but when I added settings for my django app to use cloudinary to store uploaded files in production whitenoise acted up failing to see files that are existent in my project , I have not made any changes to my static files and my previous pushes to heroku were all okay but now once the collectstatic part of the deploy starts whitenoise presents an issue of not seeing my files yet their paths are still okay and nothing has been changed in static files
Im not sure if its the cloudinary settings that are causing this
settings.py
...
INSTALLED_APPS = [
# my apps
'user.apps.UserConfig',
'store.apps.StoreConfig',
'pages.apps.PagesConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'cloudinary_storage',
'django.contrib.staticfiles',
'django.contrib.sites',
# 3rd party apps
'crispy_forms',
'allauth',
'allauth.account',
'allauth.socialaccount',
'cloudinary',
#'djangorave',
#providors
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
]
...
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
....
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
CLOUDINARY_STORAGE = {
'CLOUD_NAME': 'YOUR_CLOUD_NAME',
'API_KEY': 'YOUR_API_KEY',
'API_SECRET': 'YOUR_API_SECRET',
}
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'
project file structure showing file in question exists
error on deployment to heroku
Well apparently i missed a small detail according to the dj3-cloudinary-storage docs whereby if one only wants cloudinary to handle media files the apps 'cloudinary_storage', 'cloudinary' are placed below 'django.contrib.staticfiles' in INSTALLED_APPS as shown below
if done with the first arrangement option shown in docs with 'cloudinary_storage' coming before 'django.contrib.staticfiles', it overrides the collectstatic command causing the issue I faced above
reference: https://pypi.org/project/dj3-cloudinary-storage/