Django pipeline doesn't work at all

I have been struggling with this for hours, please help me fix this or kill me = (

I am getting 404 for all 4 files. No compiled files anywhere.

Python 3.4.0 in virtualenv, Django 1.7 RC3.

Btw:

python manage.py collectstatic

      

copies everything from assets to assets_compressed and adds admin styles. But there is an error at the end:

ValueError: The joined path (/) is located outside of the base path component (/home/val/Programming/Django/nedviga/nedviga/assets)

      

Settings:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'pipeline',
)

      

...

STATIC_URL = '/assets/'

STATIC_ROOT = os.path.join(BASE_DIR, 'assets_compressed')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'assets'),
)

      

...

PIPELINE_ENABLED = True

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'

PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'

PIPELINE_COMPILERS = (
    'pipeline.compilers.less.LessCompiler'
)

PIPELINE_CSS = {
    'libs': {
        'source_filenames': (
            'libs/bootstrap/css/bootstrap.min.css'
        ),
        'output_filename': 'css/libs.css'
    },
    'site': {
        'source_filenames': (
            'main.less'
        ),
        'output_filename': 'css/main.css'
    }
}

PIPELINE_JS = {
    'libs': {
        'source_filenames': (
            'libs/jquery/jquery-2.1.1.min.js'
            'libs/bootstrap/js/bootstrap.min.js'
        ),
        'output_filename': 'js/libs.js'
    },
    'site': {
        'source_filenames': (
            'main.js'
        ),
        'output_filename': 'js/main.js'
    }
}

      

Dir structure:

project_name

    assets
        libs
            ...
        main.js
        main.less

    assets_compressed
        *empty*

    project_name
    manage.py

      

View:

<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>AAARGH</title>

    {% load compressed %}
    {% compressed_css 'libs' %}
    {% compressed_css 'site' %}
</head>

<body>

    {% compressed_js 'libs' %}
    {% compressed_js 'site' %}
</body>

</html>

      

+3


source to share


3 answers


You need to put a comma after each source_filenames. Even if he only has one source.

For example: 'source_filenames': ( 'main.less' , ),



not

'source_filenames': ( 'main.less' ),

+2


source


Finally, I switched to django-compressor ( http://django-compressor.readthedocs.org/en/latest/ ).



But I am still open to any fixes for the problem described using the django pipeline

0


source


I don't know if it might still be useful, but you just forgot to add 'pipe.finders.PipelineFinder' to your STATICFILES_FINDERS:

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

      

0


source







All Articles