这是我的 settings.py 看起来像:
kProjectRoot = abspath(normpath(join(dirname(__file__), '..')))
MEDIA_ROOT = os.path.join(kProjectRoot, 'abc/media/')
MEDIA_URL = '/media/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'south',
'xlrd',
'pipeline',
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_YUI_BINARY='C:/Python27/Lib/site-packages/yuicompressor-2.4.8-py2.7.egg/yuicompressor'
PIPELINE_JS = {
'site': {
'source_filenames': (
'media/js/zk.base.js',
'media/js/zk.popupmenu.js',
'media/js/zk.tree.js',
'media/js/zk.treenode.js',
),
'output_filename': 'media/js/script.min.js',
}
}
我做错了什么,请指导我。我认为它应该在我的 media/js/
中创建一个 script.min.js
,我可以在 templates
中加载它。
最佳答案
你有没有运行./manage.py collectstatic --noinput
如果这不起作用,请确保这些在您的 settings.py
中并再次运行 collectstatic
,您的 Assets 将在 build
文件夹。
PIPELINE_ENABLED = True
STATICFILES_FINDERS = (
'pipeline.finders.FileSystemFinder',
'pipeline.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
'pipeline.finders.CachedFileFinder',
)
STATIC_ROOT = normpath(join(SITE_ROOT, 'build'))
STATIC_URL = '/assets/'
STATICFILES_DIRS
STATICFILES_DIRS = (
normpath(join(SITE_ROOT, 'static')),
)
INSTALLED_APPS = (
...
'django.contrib.staticfiles',
)
然后您可以通过将以下内容放入您的模板中来使用您的 Assets :
{% load compressed %}
{% compressed_js 'site' %}
希望对您有所帮助。
关于python - django-pipeline js 压缩器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21426849/