question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The file 'cms/css/cms.base.css' could not be found with CompressedManifestStaticFilesStorage

See original GitHub issue

I am stuck with this issues since yesterday, and cannot find a solution.

I use django-cookiecutter and integrated my django-cms app. Everything works fine, except when I open pages that have django-cms CSS. I get the following error:

ValueError: The file 'cms/css/cms.base.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f238b1fa610>.
  File "django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "django/template/response.py", line 109, in render
    self.content = self.rendered_content
  File "django/template/response.py", line 86, in rendered_content
    content = template.render(context, self._request)
  File "django/template/backends/django.py", line 66, in render
    return self.template.render(context)
  File "opbeat/instrumentation/packages/base.py", line 63, in __call__
    args, kwargs)
  File "opbeat/instrumentation/packages/base.py", line 222, in call_if_sampling
    return self.call(module, method, wrapped, instance, args, kwargs)
  File "opbeat/instrumentation/packages/django/template.py", line 18, in call
    return wrapped(*args, **kwargs)
  File "django/template/base.py", line 208, in render
    return self._render(context)
  File "django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 994, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 174, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 994, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 174, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 994, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 174, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 994, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 70, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 994, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "django/templatetags/static.py", line 104, in render
    url = self.url(context)
  File "cms/templatetags/cms_static.py", line 31, in url
    url = super(StaticWithVersionNode, self).url(context)
  File "django/templatetags/static.py", line 101, in url
    return self.handle_simple(path)
  File "django/templatetags/static.py", line 114, in handle_simple
    return staticfiles_storage.url(path)
  File "django/contrib/staticfiles/storage.py", line 132, in url
    hashed_name = self.stored_name(clean_name)
  File "django/contrib/staticfiles/storage.py", line 292, in stored_name
    cache_name = self.clean_name(self.hashed_name(name))
  File "django/contrib/staticfiles/storage.py", line 95, in hashed_name
    (clean_name, self))

Colelctstatic correctly copied the file and whitenoise even Post-processed the file:

django_1    | Copying '/usr/local/lib/python2.7/site-packages/cms/static/cms/css/3.4.1/cms.base.css'
django_1    | Post-processed 'cms/css/3.4.1/cms.base.css' as 'cms/css/3.4.1/cms.base.1784b3b6c6ab.css'

Here are some settings, where I believe they might have an impact:

MIDDLEWARE = (
    'django.middleware.security.SecurityMiddleware',
    'cms.middleware.utils.ApphookReloadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware',
    # Your stuff goes here (save in config.middlewares)
    'config.middlewares.RequireLoginMiddleware',
)
# STATIC FILE CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = str(ROOT_DIR('staticfiles'))

# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/'

# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = (
    str(APPS_DIR.path('static')),

)

WHITENOISE_MIDDLEWARE = ('whitenoise.middleware.WhiteNoiseMiddleware', )
MIDDLEWARE = WHITENOISE_MIDDLEWARE + MIDDLEWARE
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

Anyone any idea? Any other info you need?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:28 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
FinalAngelcommented, Sep 15, 2017

@Jafnee we are planning in about a week or two, depending on the results from testing and the help from the community.

1reaction
stefanwcommented, Jun 20, 2017

Until this is fixed I’m using a custom ManifestStaticFilesStorage:

from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
from django.core.files.storage import FileSystemStorage


class CustomManifestStaticFilesStorage(ManifestStaticFilesStorage):
    def url(self, name, force=False):
        """
        Return the non-hashed URL when detecting cms paths in order to work
        with their webpack setup
        """

        if name.startswith('cms/'):
            return FileSystemStorage.url(self, name)
        return super(CustomManifestStaticFilesStorage, self).url(name, force)

Use in settings.py like this:

STATICFILES_STORAGE = 'path.to.module.CustomManifestStaticFilesStorage'

This will exclude all static files paths starting with “cms/”. Because django-cms static file paths contain a version number, cache busting across versions should still work. Depends on Django==1.10.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The file 'cms/css/cms.base.css' could not be found ... - GitHub
I am stuck with this issues since yesterday, and cannot find a solution. I use django-cookiecutter and integrated my django-cms app.
Read more >
The file 'css/style.css' could not be found with whitenoise ...
I am trying to deploy an app using heroku. But for some reason, the static files are not loaded with whitenoise and there...
Read more >
rest_framework/css/bootstrap.min.css.map : r/django - Reddit
The CSS file 'rest_framework/css/bootstrap.min.css' references a file which could not be found: rest_framework/css/bootstrap.min.css.map.
Read more >
Solving the React Error: Not Picking Up CSS Style | Pluralsight
In this guide, you will learn about the errors that can occur while importing a CSS file into your React file.
Read more >
Theme is missing the style.css stylesheet error
A common issue that can occur when installing a WordPress themes is “The package could not be installed. The theme is missing the......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found