3

I'm trying to deploy a django react application on heroku , which uses whitenoise to handle staticfiles and cloudinary to handle media files , but when i try to run python manage.py collectstatic it returns an error 'js\canvas-to-blob.min.js' references a file whic could not be found , so i used the find static command to find the static file and discovered it was in the virtualenv folder (venv\Lib\site-packages\cloudinary\static\js\load-image.all.min.js ) and it belongs to cloudinary , when i comment out all its content , collectstatic works fine , pls is there any way to fix the error .

#installed apps
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    # 'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
    'cloudinary_storage',
    'cloudinary',
    'rest_framework',
    'corsheaders',
    'django_summernote',
    'blog.apps.BlogConfig'
]

#cloudinary storage settings
CLOUDINARY_STORAGE = {
    'CLOUD_NAME': env('CLOUD_NAME'),
    'API_KEY': env('API_KEY'),
    'API_SECRET': env('API_SECRET'),
    'STATICFILES_MANIFEST_ROOT': BASE_DIR/'static'
}
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
Dexter
  • 33
  • 5
  • I do face the same issue. – davthecoder Dec 27 '21 at 23:24
  • 2
    @davthecoder I found a tempoary solution to this , switching from STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' to STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' – Dexter Dec 29 '21 at 20:04
  • Thanks @Dexter for letting me know, I did also found some kind of solution by downgrading Django from 4.0 to 3.2.10, I guess there is some kind of issues on the latest version of Cloudinary with Django 4.0. – davthecoder Dec 30 '21 at 00:12

2 Answers2

2

This is not the real problem that cloudinary\static\js\load-image.all.min.js is in virtualenv. The problem is the cloudinary package apparently doesn't ship the .map file cloudinary\static\js\load-image.all.min.js.map.

Django 4 changed file discovery to also find sourcemap files, see e.g. https://code.djangoproject.com/ticket/33353

For now, you can use Django==3.2.13 and wait for cloudinary updates.

0

As a quick and efficient workaround you can simply add empty "canvas-to-blob.min.js.map" near "canvas-to-blob.min.js" file.

kamartem
  • 994
  • 1
  • 12
  • 22