django-pipeline DEBUG=True,未找到压缩文件

2024-04-06

好的。我对 django-pipeline 的使用简直要发疯了,离完全不使用它只有一步之遥了。 我还没有投入生产。以下所有内容都在开发中发生(DEBUG=True) 模式。我的 css 静态文件位于名为“project/static/css”的目录中,我将它们收集在名为“project/static_remote/css”的目录中(在我自己的开发服务器内)。

我设置了以下内容:

import os
from os.path import abspath, dirname, join

# PATH CONFIGURATION
here = lambda *x: join(abspath(dirname(__file__)), *x)
PROJECT_ROOT = here("..", "..")
root = lambda *x: join(abspath(PROJECT_ROOT), *x)

# STATIC FILES CONFIGURATION
STATIC_ROOT = root('static_remote')
STATIC_URL = '/static/'
STATICFILES_DIRS = (root('static'), )
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'

# PIPELINE CONFIGURATION
PIPELINE_ENABLED = True
PIPELINE_CSS = {
    'master': {
        'source_filenames': (
            'css/fonts.css',
            'css/animate.css',
            'css/style.css',
            'css/responsive.css',
        ),
        'output_filename': 'css/master.css',
    },
}

当我跑步时collectstatic一切顺利,所有文件都在master分支(加上压缩的分支,master.css)已成功复制到“project/static_remote/css”中。直到这里万岁!

但是,当我runserver然后找不到我的压缩文件{% static 'master' %}(href='/static/css/master.css')在我的模板中(显然我有{% load pipeline %})。如果我跑步,同样的情况适用findstatic 'css/master.css'。为什么会发生这种情况? 所有其他文件(fonts.css animate.css etc)是由发现findstatic.

我怀疑这是因为没有副本master.css在“项目/静态/css”内。或者发生这种情况是因为我有DEBUG = True?

如果我手动将“master.css”从“project/static_remote/css”复制到“project/static/css”,那么一切正常,但我不希望这样。请问有什么建议吗?


当 DEBUG = True 时

PIPELINE_ENABLED = 假 http://django-pipeline.readthedocs.org/en/latest/usage.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

django-pipeline DEBUG=True,未找到压缩文件 的相关文章

随机推荐