ValueError: Missing staticfiles manifest entry for 'favicon.ico'

Try running:

python manage.py collectstatic

Does the test work now? If so, this might be the configuration causing a problem:

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

as of whitenoise v4 this will fail and you should use:

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

Related:
https://stackoverflow.com/a/32347324/2596187

Check out the Django documentation: https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict


If you want to continue to use the WhiteNoise module in your Django 1.11 (or newer) project while preventing this "Missing staticfiles manifest entry" error, you need to disable the manifest_strict attribute by means of inheritance, as noted in Django documentation.

How to accomplish that?

Firstly, create a storage.py file in your project directory:

from whitenoise.storage import CompressedManifestStaticFilesStorage


class WhiteNoiseStaticFilesStorage(CompressedManifestStaticFilesStorage):
    manifest_strict = False

Secondly, edit the STATICFILES_STORAGE constant in your settings.py file to point to this new class, such as:

STATICFILES_STORAGE = 'my_project.storage.WhiteNoiseStaticFilesStorage'

Just sharing the solution I had to this issue in case it helps anyone else.

I was accidentally including the leading "/" in some static URLs which caused them to be missing from the manifest.

The solution was to replace all instances of:

{% static '/path/to/some/file' %}

with

{% static 'path/to/some/file' %}

and then everything worked properly.


That not necessarily happens with whitenoise package. Changing STATIC_STORAGE to django.contrib.staticfiles.storage.ManifestStaticFilesStorage will produce the same error while running tests starting with Django 1.11.

That happens because ManifestStaticFilesStorage expects staticfiles.json to exist and contain the file asked. You can confirm this by running ./manage.py collectstatic and trying again.

You don't generally see this error in development because when DEBUG == True, ManifestStaticFilesStorage switches to non-hashed urls.

To overcome this you've got to make sure that:

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'

Which is the default.

One way would be to override settings for the test class:

from django.test import TestCase, override_settings
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
class MyTest(TestCase):
    pass

or the method:

from django.test import TestCase, override_settings
class MyTest(TestCase):
    @override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
    def test_something(self):
        pass