首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >django-管道抛出ValueError:找不到该文件

django-管道抛出ValueError:找不到该文件
EN

Stack Overflow用户
提问于 2016-10-12 23:39:52
回答 2查看 2.2K关注 0票数 2

在运行python manage.py collectstatic --noinput时,我会得到以下错误:

代码语言:javascript
运行
复制
Post-processing 'jquery-ui-dist/jquery-ui.css' failed!
Traceback (most recent call last):
File "manage_local.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle
collected = self.collect()
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 145, in collect
raise processed
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 257, in post_process
content = pattern.sub(converter, content)
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 187, in converter
hashed_url = self.url(unquote(target_name), force=True)
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 132, in url
hashed_name = self.stored_name(clean_name)
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 292, in stored_name
cache_name = self.clean_name(self.hashed_name(name))
File "/Users/michaelbates/GoogleDrive/Development/inl/venv/lib/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 95, in hashed_name
(clean_name, self))
ValueError: The file 'jquery-ui-dist/"images/ui-icons_555555_256x240.png"' could not be found with <pipeline.storage.PipelineCachedStorage object at 0x1073e2c50>.

如果我运行python manage.py findstatic jquery-ui-dist/"images/ui-icons_555555_256x240.png",就会得到:

代码语言:javascript
运行
复制
Found 'jquery-ui-dist/images/ui-icons_555555_256x240.png' here:
      /Users/michaelbates/GoogleDrive/Development/inl/node_modules/jquery-ui-dist/images/ui-icons_555555_256x240.png
      /Users/michaelbates/GoogleDrive/Development/inl/staticfiles/jquery-ui-dist/images/ui-icons_555555_256x240.png

以下是一些相关的设置:

代码语言:javascript
运行
复制
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'pipeline.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
    os.path.join(BASE_DIR, 'node_modules'),
)

我的PIPELINE设置dict很大,所以我不会发布全部内容,但其中的一些部分是:

代码语言:javascript
运行
复制
PIPELINE = {
    'STYLESHEETS': {
        'pricing': {
            'source_filenames': (
                'jquery-ui-dist/jquery-ui.min.css',
            ),
            'output_filename': 'css/pricing.min.css'
        },
    }
    'JS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
    'CSS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
    'COMPILERS': (
        'pipeline.compilers.sass.SASSCompiler',
    )
}

我尝试过将STATICFILES_FINDERS更改为django管道特定的那些,但这并没有什么区别。

有人能解释一下为什么在收集过程中找不到那个png文件,但是可以用findstatic找到它吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-10-19 21:47:59

您的问题与Django项目的这只虫子有关。

简而言之,Django-管道是使用Django的url() CachedStaticFilesStorage对md5调用进行后处理,以便将md5校验和附加到文件名(这里有更多的细节)中,而不会检测到它何时在注释中。

如果您查看jquery-ui.css (和类似的)文件的头,有一个注释以

  • 要查看和修改这个主题,请访问..。

在这行的URL中,有一个参数被解释为一个url()调用,并生成您看到的错误。

为了解决这个问题,您可以简单地从jquery-ui.css中删除上面的行,collectstatic应该正常工作。

票数 7
EN

Stack Overflow用户

发布于 2021-02-06 07:49:22

正如马西奥所说,您可以从css文件中删除url或使用标志--no-post-process

代码语言:javascript
运行
复制
manage.py collectstatic --no-post-process
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40010040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档