django-libsass is a Django Compressor filter that compiles Sass (SCSS) files using the `libsass-python` binding of LibSass. It integrates seamlessly into Django's static files and compressor pipeline, allowing developers to write Sass without external build tools. The current version is 0.9, and it receives infrequent but active maintenance updates for Django compatibility.
pip install django-libsass django-compressor libsassVerified import paths — ran on the pinned version, not inferred.
To quickly integrate `django-libsass`, first ensure `django-compressor` is set up. Add `compressor` to `INSTALLED_APPS` and `compressor.finders.CompressorFinder` to `STATICFILES_FINDERS`. Then, configure `COMPRESS_PRECOMPILERS` in your `settings.py` to use `django_libsass.SassCompiler` for `text/x-scss` files. Finally, in your Django templates, load the `compress` and `static` tags and wrap your SCSS `link` tag within `{% compress css %}` and `{% endcompress %}` blocks, specifying `type="text/x-scss"`.
Be aware of potential future limitations. For new projects, evaluate alternatives like `django-sass-processor` with Dart Sass if cutting-edge Sass features are required.
Always use the latest stable version of `django-libsass` to ensure compatibility with your Django and `django-compressor` versions. Check release notes for specific version requirements.
Set `LIBSASS_PRECISION = 8` (or higher if needed) in your `settings.py` when using such frameworks.
Organize your SCSS files so that `@import` paths are relative to a recognized static files directory or an entry in `LIBSASS_ADDITIONAL_INCLUDE_PATHS`. Avoid `../` in `@import` statements.
Ensure only `libsass` (via `pip install libsass`) is installed as your Sass compiler if you are using `django-libsass`. Uninstall other conflicting Sass-related Python packages.