Skip to content

Manifest has leading slash, but staticfiles expects none #54

@WhyNotHugo

Description

@WhyNotHugo

Trying to use this in non-debug mode fails:

self = <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7fe1adb9b670>, name = '/css/app.f6e28323.css'

    def stored_name(self, name):
        parsed_name = urlsplit(unquote(name))
        clean_name = parsed_name.path.strip()
        hash_key = self.hash_key(clean_name)
        cache_name = self.hashed_files.get(hash_key)
        if cache_name is None:
            if self.manifest_strict:
>               raise ValueError(
                    "Missing staticfiles manifest entry for '%s'" % clean_name
                )
E               ValueError: Missing staticfiles manifest entry for '/css/app.f6e28323.css'

/usr/local/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py:465: ValueError

From what I can tell, the issue is that django-manifest-loader attempts to find files in the staticfiles stoage using the path found in manifest.json. The issue is that paths in manifest.json have a leading slash, but paths in staticfiles.json do not.

E.g.:

$ jq < manifest.json| grep css.app
  "app.css": "/css/app.f6e28323.css",
$ jq < staticfiles.json |  grep f6e28323
    "css/app.f6e28323.css": "css/app.f6e28323.d95a1d9dad84.css",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions