I\'m trying to serve static files through WhiteNoise as per Heroku\'s recommendation. When I run collectstatic
in my development environment, this happens:
I just had this same issue and fixed it by removing this line from my settings file,
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
I got this line from the Heroku documentation page...
For me the fix was simply adding a 'static' folder to the top directory (myapp/static did the trick). If you are setting the STATIC_URL but don't have that directory already created, it will throw an error, even though you aren't using that directory for your static files with whitenoise.
STATIC_URL = '/static/'
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
It worked for me by commenting out the whitenoise in settings.py in production.
#STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
#WHITENOISE_ROOT = os.path.join(BASE_DIR, 'staticfiles')
Be sure to check all your settings related to static files, especially making sure the paths are pointing to the right locations. I personally had one of my STATICFILES_DIRS
pointing to a wrong path.
There are two options: