django-storages icon indicating copy to clipboard operation
django-storages copied to clipboard

S3ManifestStaticStorage - ValueError: Missing staticfiles manifest entry for ''

Open tsantor opened this issue 3 years ago • 3 comments

When using S3ManifestStaticStorage, even with manifest_strict = False, I continue to get ValueError: Missing staticfiles manifest entry for ''. From what I've read, setting manifest_strict to False should ignore these ValueErrors.

This is how I have it setup:

project/utils/storages.py

from storages.backends.s3boto3 import S3ManifestStaticStorage

class ManifestS3Storage(S3ManifestStaticStorage):
    location = "static"
    default_acl = "public-read"
    manifest_strict = False

config/settings/production.py STATICFILES_STORAGE = "project.utils.storages.ManifestS3Storage"

Considering ValueError: Missing staticfiles manifest entry for '' isn't very helpful because it doesn't contain a file name, I tried to see where it is finding ''. But this leads me nowhere and to 3rd party packages.

Running python manage.py findstatic --verbosity 2 '' returns:

Found '' here:
  /project/static
  /usr/local/lib/python3.8/site-packages/django/contrib/admin/static
  /usr/local/lib/python3.8/site-packages/rest_framework/static
  /usr/local/lib/python3.8/site-packages/drf_yasg/static
  /usr/local/lib/python3.8/site-packages/ckeditor/static
  /usr/local/lib/python3.8/site-packages/adminsortable2/static

tsantor avatar May 27 '21 09:05 tsantor

good job!

goltsevnet avatar Oct 22 '21 04:10 goltsevnet

I had this issue as well.

Google only turns this result up so I am leaving this comment, even though I am using the regular Django static file storage ('django.contrib.staticfiles.storage.ManifestStaticFilesStorage')

In my case subclassing ManifestStaticFilesStorage from django.contrib.staticfiles.storage fixed the error just as you describe, exactly as you did.

virgil9306 avatar Nov 13 '21 01:11 virgil9306

We had this issue also in our code. Turned out because we had this static('') call:

from django.templatetags.static import static

FRONTEND_STATIC_BASE_URL = static('')

The intention is to get the S3 base static URL, for example: https://foo-bar-web-files.s3.amazonaws.com/static/

But, since we have these settings also:

AWS_S3_CUSTOM_DOMAIN = 'foo-bar-web-files.s3.amazonaws.com'
STATIC_S3_LOCATION = 'static'
STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, STATIC_S3_LOCATION)

We simply converted the triggering code to this:

from django.conf import settings

FRONTEND_STATIC_BASE_URL = settings.STATIC_URL

to avoid the static('') call since the manifest_strict = False is not enough, and will just trigger another error upstream.

Likewise, this seems to be more of the failure of Django to handle an empty file name when using static storage, and not really a bug in django-storages.

ranelpadon avatar May 04 '22 16:05 ranelpadon