2

这是我的 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',
    }
}

我在做什么错,请指导我。我认为它应该script.min.js在我media/js/templates.

4

2 回答 2

1

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

如果这不起作用,请确保这些在您的文件中settings.pycollectstatic再次运行,您的资产将位于该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' %}

希望能帮助到你。

于 2014-03-04T08:13:01.823 回答
0

用正\斜杠替换./PIPELINE_YUI_BINARY

于 2014-01-29T10:11:55.167 回答