Django SASS Processor

1.4.2 · active · verified Thu Apr 16

Django SASS Processor compiles SCSS files into CSS dynamically during development or offline for production. It integrates seamlessly with Django's staticfiles system and provides template tags for easy inclusion of compiled CSS in templates. The current version is 1.4.2, with minor releases occurring every few months, and major versions (like 1.0.0) introducing breaking changes less frequently.

Common errors

Warnings

Install

Imports

Quickstart

Configure `django-sass-processor` by adding it to `INSTALLED_APPS` and defining `SASS_PROCESSOR_ROOT`. Then, load the `sass_tags` in your templates to reference your compiled SCSS files. Remember to run `python manage.py collectstatic` in production.

import os

# settings.py snippet

INSTALLED_APPS = [
    # ... other Django apps
    'django.contrib.staticfiles',
    'sass_processor',
]

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'staticfiles')

# Define where your SCSS files are located
SASS_PROCESSOR_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sass')

# Example template (e.g., templates/base.html)
# Make sure to create a directory 'sass' in your project root
# and add an example.scss file: sass/example.scss
# body {
#   color: blue;
# }

# To test, create a file named 'example.scss' in the SASS_PROCESSOR_ROOT directory:
# $body-color: blue;
# body {
#   color: $body-color;
# }

view raw JSON →