Quickstart¶
Installation¶
Install Django Compressor with your favorite Python package manager:
pip install django_compressor
Add
'compressor'to yourINSTALLED_APPSsetting:INSTALLED_APPS = ( # other apps "compressor", )
See the list of Settings to modify Django Compressor’s default behaviour and make adjustments for your website.
In case you use Django’s staticfiles contrib app you have to add Django Compressor’s file finder to the
STATICFILES_FINDERSsetting, like this:STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # other finders.. 'compressor.finders.CompressorFinder', )
Define
COMPRESS_ROOTin settings if you don’t have alreadySTATIC_ROOTor if you want it in a different folder.
Optional Dependencies¶
-
For the
parsercompressor.parser.BeautifulSoupParserandcompressor.parser.LxmlParser:pip install beautifulsoup4
-
For the
parsercompressor.parser.LxmlParser, also requires libxml2:STATIC_DEPS=true pip install lxml
-
For the
parsercompressor.parser.Html5LibParser:pip install html5lib
-
For the Calmjs filter
compressor.filters.jsmin.CalmjsFilter:pip install calmjs.parse
-
For the csscompressor filter
compressor.filters.cssmin.CSSCompressorFilter:pip install csscompressor
-
For brotli file compressor compressor.storage.BrotliCompressorFileStorage:
pip install brotli