我试图让 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/