curiousguy
curiousguy

Reputation: 3262

django-pipeline js compressor is not working

This is my settings.py looks like :

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',
    }
}

What is the mistake i am doing , please guide me . I think that it should create a script.min.js in my media/js/ , which i can load in templates.

Upvotes: 2

Views: 759

Answers (2)

bit2pixel
bit2pixel

Reputation: 1142

Did you run ./manage.py collectstatic --noinput

If that doesn't work, make sure these are in your settings.py and run collectstatic again, your assets will be under the build folder.

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',
)

Then you can use your assets by putting the following in your template:

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

Hope it helps.

Upvotes: 1

xyres
xyres

Reputation: 21779

Replace back-slashes \ with forward-slashes / in the path of PIPELINE_YUI_BINARY.

Upvotes: 0

Related Questions