首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么django-管道不收集静态?

为什么django-管道不收集静态?
EN

Stack Overflow用户
提问于 2017-08-03 15:45:07
回答 1查看 479关注 0票数 2

我跟踪了django-管道文档,在收集静态文件时遇到了问题,控制台显示没有找到指定的文件。

收集工作没有djanog-管道。我还试图在与manage.py没有任何区别的同一级别添加静态文件.

下面是我的应用程序树的配置方式:

代码语言:javascript
复制
Globalapp : (root folder)
    - src (the base that contains all my django files)
        -- staticfiles (folder here after collectstatic)

        -- manage.py (file)

        -- app (folder, where settings.py is)
           ...
        -- pages (folder, where static files are)
           --- static
               - css
                 -- main.css
...

下面是我如何配置我的settings.py

代码语言:javascript
复制
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

INSTALLED_APPS = [
    ...
    'pipeline',
]

...

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
#tried : STATIC_ROOT = os.path.join(BASE_DIR, 'pages')

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

PIPELINE = {
    'COMPILERS': (
        'pipeline.compilers.stylus.StylusCompiler',
    ),
    'STYLESHEETS': {
        'pages': {
            'source_filenames': (
              'css/main.css',
            ),
            'output_filename': 'designer.css',
        },
    },
}

我现在在本地主机上工作,运行python manage.py collectstatic时发生错误,我做错什么了吗?

这是回溯:

代码语言:javascript
复制
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python34\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python34\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Python34\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 199, in handle
    collected = self.collect()
  File "C:\Python34\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 139, in collect
    for original_path, processed_path, processed in processor:
  File "C:\Python34\lib\site-packages\pipeline\storage.py", line 26, in post_process
    packager.pack_stylesheets(package)
  File "C:\Python34\lib\site-packages\pipeline\packager.py", line 100, in pack_stylesheets
    variant=package.variant, **kwargs)
  File "C:\Python34\lib\site-packages\pipeline\packager.py", line 118, in pack
    content = compress(paths, **kwargs)
  File "C:\Python34\lib\site-packages\pipeline\compressors\__init__.py", line 78, in compress_css
    css = getattr(compressor(verbose=self.verbose), 'compress_css')(css)
  File "C:\Python34\lib\site-packages\pipeline\compressors\yuglify.py", line 20, in compress_css
    return self.compress_common(css, 'css', settings.YUGLIFY_CSS_ARGUMENTS)
  File "C:\Python34\lib\site-packages\pipeline\compressors\yuglify.py", line 14, in compress_common
    return self.execute_command(command, content)
  File "C:\Python34\lib\site-packages\pipeline\compressors\__init__.py", line 247, in execute_command
    stdin=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Python34\lib\subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1114, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The specified path to the file was not found.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-04 15:13:47

最后我使用了django-压缩机django-sass-处理器。它就像django管道一样工作,我找不到这个具体问题的原因,但是所有其他的包都解决了,当组合在一起时,这些包所做的事情与管道几乎相同。

如果您在使用pip安装django-压缩程序时遇到问题,请尝试使用以下命令:

代码语言:javascript
复制
pip install rcssmin --install-option="--without-c-extensions"
pip install rjsmin --install-option="--without-c-extensions"
pip install django-compressor --upgrade
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45488959

复制
相关文章

相似问题

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