问题描述
我试图按照提供静态文件= https://devcenter.heroku.com/articles/django-assets> Heroku 的推荐。当我在开发环境中运行 collectstatic
时,会发生这种情况:
Post -处理'css / iconic / open-iconic-bootstrap.css'失败!
追溯(最近一次通话):
文件 ./manage.py,第10行,在< module>中。
execute_from_command_line(sys.argv)
文件 /home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/management/__init__.py,第385行,在execute_from_command_line
utility.execute()
文件 /home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/management/__init__.py中,行377 ,在执行
self.fetch_command(subcommand).run_from_argv(self.argv)
File /home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/core/ management / base.py,第288行,位于run_from_argv
self.execute(* args,** options .__ dict__)
文件 /home/Pieter/.virtualenvs/radiant/lib/python3.4 /site-packages/django/core/management/base.py,行338,在执行
输出= self.handle(* args,** options)
文件 / home / Pieter /中。 virtualenvs / radiant / lib / python3.4 / site-packages / django / core / management / base.py,第533行,在句柄
中,返回self.handle_noargs(** options)
文件 /主页/Pieter/.virtualenvs/radia nt / lib / python3.4 / site-packages / django / contrib / staticfiles / management / commands / collectstatic.py,行168,在handle_noargs中
collect = self.collect()
File /主页/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py,第120行,在收集
中处理
文件 /home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py,行242,在post_process
content = pattern.sub(converter,content )
文件 /home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py,第181行,在转换器
hashed_url = self中.url(unquote(joined_result),force = True)
文件 /home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py,行128,在网址
hashed_name = self.stored_name(clean_name)
File /home/Pieter/.virtualenvs/radiant/lib/python3.4/site-packag es / django / contrib / staticfiles / storage.py,第277行,位于stored_name
cache_name = self.clean_name(self.hashed_name(name))
文件 /home/Pieter/.virtualenvs/radiant /lib/python3.4/site-packages/django/contrib/staticfiles/storage.py,第91行,位于hashed_name
(clean_name,self))
ValueError:文件'css / fonts /无法通过< whitenoise.django.GzipManifestStaticFilesStorage对象位于0x7f57fc5b1550>找到open-iconic.eot。
当我在设置中注释掉此行时,静态收集命令运行不会发生意外:
STATICFILES_STORAGE ='whitenoise.django.GzipManifestStaticFilesStorage'
这里出了什么问题,我该如何解决?我已经尝试清空静态文件输出文件夹。它运行平稳,直到开始处理一个特定文件为止。
这里的问题是 css / iconic /open-iconic-bootstrap.css
引用文件 open-iconic.eot
,该文件不存在于预期位置。 / p>
在该存储后端运行 collectstatic
时,Django尝试重写CSS文件中的所有URL,以便它们引用文件的新名称,例如 css / iconic / open-iconic.8a7442ca6bed.eot
。如果找不到文件,它将停止并显示该错误。
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.
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.
这篇关于启用WhiteNoise后,“ collectstatic”命令失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!