'collectstatic' command fails when WhiteNoise is enabled

前端 未结 14 1020
别那么骄傲
别那么骄傲 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:22

    In development Django’s runserver automatically takes over static file handling.

    In most cases this is fine, however this means that some of the improvements that WhiteNoise makes to static file handling won’t be available in development and it opens up the possibility for differences in behaviour between development and production environments. For this reason it’s a good idea to use WhiteNoise in development as well.

    You can disable Django’s static file handling and allow WhiteNoise to take over simply by passing the --nostatic option to the runserver command, but you need to remember to add this option every time you call runserver. An easier way is to edit your settings.py file and add whitenoise.runserver_nostatic to the top of your INSTALLED_APPS list:

    INSTALLED_APPS = [
    'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
    # ...]
    

    Source - http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development

提交回复
热议问题