Django-css is dead, long live Django Compressor
This announcement is long past due. When I originally forked django-css from django-compressor the Django landscape and state of django-compressor were very different. The main impetus for the fork was to be able to use CSS compilers and fix some outstanding bugs.
Since then, django-compressor has been taken over and revitalized by Jannis Leidel. Not only is there a lot more active development, but it has a pre-compiler feature which allows you to easily plug in your favorite CSS and JS compilers. Since the original goals of django-css are now being met and surpassed by its parent, I think the responsible thing to do is officially kill django-css and recommend that people migrate to django-compressor.
github: https://github.com/jezdez/django_compressor
documentation: http://django_compressor.readthedocs.org
pypi: http://pypi.python.org/pypi/django_compressor
Migrating from django-css to django-compressor
For the most part, settings and usage and very similar. You should probably read the excellent documentation before you do anything, but I just want to highlight the main difference in how django-css and django-compressor handle pre-compilation of files.
Let’s assume my django-css setup looks like this:
HTML:
{% load compress %}
{% compress css %}
<link rel="stylesheet" href="/media/css/one.css" type="text/css" charset="utf-8">
<link rel="stylesheet" href="/media/css/two.sass" type="text/css" charset="utf-8">
{% endcompress %}
Settings.py:
COMPILER_FORMATS = {
'.sass': {
'binary_path':'/path/to/sass',
'arguments': '*.sass *.css'
}
}
The equivalent django-compressor code would look like this:
HTML:
{% load compress %}
{% compress css %}
<link rel="stylesheet" href="/media/css/one.css" type="text/css" charset="utf-8">
<link rel="stylesheet" href="/media/css/two.sass" type="text/x-sass" charset="utf-8">
{% endcompress %}
Settings.py:
COMPRESS_PRECOMPILERS = (
('text/x-sass', 'sass {infile} {outfile}'),
)
That’s basically it, but for more info check out the COMPRESS_PRECOMPILER setting in the docs.