3

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/'

5
  • You need to specify relative paths to files, isn't you? Commented Mar 20, 2012 at 5:10
  • @neoasceetic i have static files out of the source folder. So i think that if i use relative paths the files aren't found. Commented Mar 20, 2012 at 7:05
  • Why so? Static files must be inside your source dir by defenition, unlike media files Commented Mar 20, 2012 at 9:27
  • Because source folder, that contains python code, is private, but the js and css files are public, so i have to distinguish this fact. Commented Mar 20, 2012 at 9:33
  • Why not copy/link this files? Commented Mar 20, 2012 at 9:48

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

10 Comments

In this way the relative path starts from? From source folder? From project root folder? If my project containes /myproject/static /myproject/src myproject/media, relative path start from /myproject folder? Or?
Paths starts from static folder. Because you can have many apps within your project and each can have static files inside it. So, if you have /myproject/static/css/main.css, relative path is css/main.css
Now i use relative path (for example 'css/colors/colors.css' ), but collectstatic doesn't generate the compressed files in STATIC_ROOT folder
Do you specify STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage' in your settings?
No, but just now i have added this setting, but the result is bad. No files are generated in STATIC_ROOT. Howeve now i will edit the question to specify better my settings.py
|
0

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' %} )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.