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 had similar problem, but with a twist.
I deployed on pythonanywhere. If I turn debug True, app runs fine. But if a turn debug False, app crashes with a error that with one line being the summary
ValueError: Missing staticfiles manifest entry for 'favicons/favicon.ico'
I changed from STATIC_ROOT = 'staticfiles
to STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
Deleted staticfiles
directory, then rerun python manage.py collectstatic
.
Now app runs fine
I've been dealing with this issue all day. It turns out the problem was the staticfiles
directory was not checked in to git. I created a dummy file inside this directory, checked it in and everything was fine. This was mentioned somewhere in the Whitenoise documentation too, I believe.
Much like everyone else, I had a unique fix to this problem... turns out I had a url()
in my styles.css
file with bad syntax.
Once I changed:
background-image: url( '../images/futura_front_blank_medium.jpg' );
to
background-image: url('../images/futura_front_blank_medium.jpg');
(notice the subtle difference -- I removed the spaces on either side of the string)
then python manage.py collectstatic
worked fine and I didn't get that error.
The whitenoise.django.GzipManifestStaticFilesStorage
alias has now been removed. Instead you should use the correct import path: whitenoise.storage.CompressedManifestStaticFilesStorage
.
As per the doc here.
I've had this error claiming a missing .css file when all my .css files existed, because I trusted Heroku documentation:
STATIC_ROOT = 'staticfiles'
over WhiteNoise documentation:
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
The fix is trivial, but until Heroku fix their docs (I submitted feedback), lets make sure the solution at least appears in SO.
In my case there was another solution. In Heroku config I had a setting:
DISABLE_COLLECTSTATIC=0
which should let Heroku collect static automaticly by pushing to heroku master, but it didn`t!.
What I did was removing this setting on
Heroku > my_app > settings > config vars
and after that Heroku collected staticfiles automaticly and problem dissappeard.