'collectstatic' command fails when WhiteNoise is enabled

前端 未结 14 1015
别那么骄傲
别那么骄傲 2020-12-08 19:51

I\'m trying to serve static files through WhiteNoise as per Heroku\'s recommendation. When I run collectstatic in my development environment, this happens:

14条回答
  •  心在旅途
    2020-12-08 20:36

    The issue here is that using

    STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

    or

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

    uses Django's static file storage in a different way than runserver does. See the Django docs for some explanation: https://docs.djangoproject.com/en/1.11/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict

    I believe the referenced manifest gets built when you run collectstatic, so doing so should fix this problem temporarily, but you likely don't want to run collectstatic before every test run if you have modified any static files. Another solution would be to disable this setting for your tests, and just run it in production.

提交回复
热议问题