Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

python - 'collectstatic' command fails when WhiteNoise is enabled

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

Post-processing 'css/iconic/open-iconic-bootstrap.css' failed!

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/management/base.py", line 533, in handle
    return self.handle_noargs(**options)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle_noargs
    collected = self.collect()
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 120, in collect
    raise processed
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 242, in post_process
    content = pattern.sub(converter, content)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 181, in converter
    hashed_url = self.url(unquote(joined_result), force=True)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 128, in url
    hashed_name = self.stored_name(clean_name)
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 277, in stored_name
    cache_name = self.clean_name(self.hashed_name(name))
  File "/home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 91, in hashed_name
    (clean_name, self))
ValueError: The file 'css/fonts/open-iconic.eot' could not be found with <whitenoise.django.GzipManifestStaticFilesStorage object at 0x7f57fc5b1550>.

The static collection command runs without incident when I comment out this line in my settings:

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

What's going wrong here and how do I fix it? I already tried emptying my static file output folder. It runs smoothly until it starts processing one specific file.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem here is that css/iconic/open-iconic-bootstrap.css is referencing a file, open-iconic.eot, which doesn't exist in the expected location.

When you run collectstatic with that storage backend Django attempts to rewrite all the URLs in your CSS files so they reference the files by their new names e.g, css/iconic/open-iconic.8a7442ca6bed.eot. If it can't find the file it stops with that error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...