Search code examples
djangowhitenoise

Module "whitenoise.storage" does not define a "CompressedMainfestStaticFilesStorage" attribute/class


I'm using whitenoise to serve static files in my Django project. Here is the settings.py

STATIC_URL = 'data/static/'
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'data/static/'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

I have my static files in data/static folder. When I try to run python manage.py collectstatic after commenting this line:

STATICFILES_STORAGE = 'whitenoise.storage.CompressedMainfestStaticFilesStorage'

It runs fine. But when I try to run collectstatic after uncommenting this, it gives the above error. Anyone has any idea as to why is this an error?

Here are the apps and middleware:

INSTALLED_APPS = [
    'admin_interface',
    'colorfield',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
    'app',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

And I have tried setting Debug to True and False but it doesn't work in either cases with compression on.


Solution

  • You have a typo in the class name. It's CompressedManifestStaticFilesStorage, not Mainfest. I'll recommend always copy-pasting from docs if you don't have support for this kind of completions in your IDE.