Django Compress: New CSS Filter

I added a new filter today for django-compress that allows for arbitrary string find/replace during the compile process on your css groups.


I had a specific use case for the new filter: my css had a lot of root relative urls for background images. I wanted to host my compiled media on a different host than where my images were being hosted from but this tied the two together.

Furthermore, I didn’t want to hard code the absolute urls as I want to be able to test the full environment on my laptop, test environments and finally be able to deploy somewhere else in production. I want the process of changing environments to be simple settings file change.

Therefore, my approach was to [create a filter that at compile time execute a string find and replace](http://github.com/paltman/django- compress/commit/5038b5b04252767a1ae8766423baca5a6c6a94a2). It’s super simple, but useful, at least to me.

I also found what I think were a couple of bugs when you had some groups with external_urls defined. When they were missing source_filenames and output_filenames definitions, exceptions were raised when running the management command to compile the source. I put some simple checks in place to safe guard against these exceptions.