'collectstatic' command fails when WhiteNoise is enabled

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

    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

    0 讨论(0)
  • 2020-12-08 20:26

    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.

    0 讨论(0)
  • 2020-12-08 20:26

    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.

    0 讨论(0)
  • 2020-12-08 20:28

    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.

    0 讨论(0)
  • 2020-12-08 20:31

    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.

    0 讨论(0)
  • 2020-12-08 20:32

    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.

    0 讨论(0)
提交回复
热议问题