Giovanni Bitliner
Giovanni Bitliner

Reputation: 2072

Django + Pipeline to compress css: 404 for the output_filename css file

Configuration of Pipeline to compress css files is this:

PIPELINE_CSS = {
                'colors': {
                          'source_filenames': (
                                               '/static/css/colors/colors.css',
                                               '/static/css/colors/layout.css'
                                               ),
                          'output_filename': '/static/css/Colors.css',
                    },
                }

but when the client tries to get

/static/css/Colors.css with

{% load compressed %}    
{% compressed_css 'colors' %} 

it returns 404, Not found. If i run collectstatic no files (like /static/css/Colors.css) are generated in STATIC_ROOT.

I have installed YUI Compressor from Synaptic Repository of my Ubuntu Lucid.

EDIT1: Other of settings.py:

PIPELINE_STORAGE = 'pipeline.storage.PipelineFinderStorage'

STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'

PIPELINE=True

In middleware classes:

'django.middleware.gzip.GZipMiddleware',

'pipeline.middleware.MinifyHTMLMiddleware',

STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )

STATICFILES_DIRS = ( "/home/my/eclipse/myproject/static/", )

STATIC_URL = '/static/'

STATIC_ROOT = '/home/my/eclipse/myproject/static2/'

Upvotes: 3

Views: 2417

Answers (2)

Alex
Alex

Reputation: 6037

What is the last line when you run collectstatic?

I noticed it writes to /tmp instead of STATIC_ROOT .

removing these 2 lines seems to fix it:

PIPELINE_STORAGE = 'pipeline.storage.PipelineFinderStorage'
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage' 

( btw, the syntax has changed to {% load pipeline %} {% stylesheet 'colors' %} )

Upvotes: 0

neoascetic
neoascetic

Reputation: 2546

You need to use relative paths to source files since pipeline use staticfiles app to find this files.

Read more about staticfiles management in Django

Upvotes: 1

Related Questions