django-pipeline 不起作用

标签 django django-pipeline

我试图让 django-pipeline 工作,但它就是不起作用。以下是我的设置。我在应用程序部分添加了“管道”。

这是我尝试打开网站时出现的错误: “设置”对象没有属性“PIPELINE”

以下是我的设置:

STATIC_URL = '/static/'

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

STATIC_ROOT = os.path.join(BASE_DIR, 'static_cdn')

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

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

PIPELINE_JS = {
    'stats': {
        'source_filenames': (
          'js/base.js',
        ),
        'output_filename': 'site-js-min.js',
    }
}


PIPELINE_CSS = {
    'colors': {
        'source_filenames': (
          'css/base.css',
        ),
        'output_filename': 'site-css-min.css',
        'variant': 'datauri',
        'extra_context': {
            'media': 'screen,projection',
        }
    }
}

最佳答案

As per the docs ,您需要在 settings.py 中定义 PIPELINE 变量,如下所示,

PIPELINE = {
    'PIPELINE_ENABLED': True,
    'JAVASCRIPT': {
        'stats': {
            'source_filenames': (
              'js/jquery.js',
              'js/d3.js',
              'js/collections/*.js',
              'js/application.js',
            ),
            'output_filename': 'js/stats.js',
        }
    }
}

关于django-pipeline 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36027297/

相关文章:

Django/postgres 事务隔离级别设置被忽略

python - 如何在 Python 中转义撇号等?

python - 使用 django-pipeline 动态压缩静态文件

Django 管道找不到静态 css 文件

Django:按位置排序忽略 NULL

python - 是否可以通过 django 输入表单传递动态 id

python - 在一个查询中汇总来自不同表的数值

django - 为什么 django-pipeline 的 {%compressed_js ... %} 标签会分别输出每个脚本?

当 DEBUG=False 时 django 管道会中断管理