【问题标题】:django-pipeline js compressor is not workingdjango-pipeline js 压缩器不工作
【发布时间】:2014-01-29 09:25:29
【问题描述】:

这是我的 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 中加载它。

【问题讨论】:

  • 是的,同样的问题。只能在Windows下重现

标签: python django django-pipeline


【解决方案1】:

你跑了吗./manage.py collectstatic --noinput

如果这不起作用,请确保这些在您的 settings.py 中并再次运行 collectstatic,您的资产将位于 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',
)

然后您可以通过将以下内容放入模板中来使用您的资产:

{% load compressed %}
{% compressed_js 'site' %}

希望对你有帮助。

【讨论】:

    【解决方案2】:

    PIPELINE_YUI_BINARY 的路径中将反斜杠\ 替换为正斜杠/

    【讨论】:

    • 此更改后没有改善:(
    猜你喜欢
    • 2012-04-29
    • 1970-01-01
    • 2015-10-19
    • 1970-01-01
    • 2015-07-31
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 2012-04-04
    相关资源
    最近更新 更多