{"id":18605258,"url":"https://github.com/coderedcorp/django-sass","last_synced_at":"2025-07-04T20:35:58.398Z","repository":{"id":47613827,"uuid":"186026377","full_name":"coderedcorp/django-sass","owner":"coderedcorp","description":"The absolute simplest way to use Sass with Django. Pure Python, minimal dependencies, no special configuration required!","archived":false,"fork":false,"pushed_at":"2021-08-21T19:16:43.000Z","size":53,"stargazers_count":75,"open_issues_count":4,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-26T09:38:17.726Z","etag":null,"topics":["django","sass","web-development-tools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderedcorp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-10T17:16:52.000Z","updated_at":"2025-05-11T20:15:13.000Z","dependencies_parsed_at":"2022-07-21T16:34:42.466Z","dependency_job_id":null,"html_url":"https://github.com/coderedcorp/django-sass","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/coderedcorp/django-sass","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderedcorp%2Fdjango-sass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderedcorp%2Fdjango-sass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderedcorp%2Fdjango-sass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderedcorp%2Fdjango-sass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderedcorp","download_url":"https://codeload.github.com/coderedcorp/django-sass/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderedcorp%2Fdjango-sass/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262532967,"owners_count":23325159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","sass","web-development-tools"],"created_at":"2024-11-07T02:20:30.650Z","updated_at":"2025-07-04T20:35:58.346Z","avatar_url":"https://github.com/coderedcorp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-sass\n===========\n\nThe absolute simplest way to use [Sass](https://sass-lang.com/) with Django.\nPure Python, minimal dependencies, and no special configuration required.\n\n[Source code on GitHub](https://github.com/coderedcorp/django-sass)\n\n\nStatus\n------\n\n|                        |                      |\n|------------------------|----------------------|\n| Python Package         | [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-sass)](https://pypi.org/project/django-sass/) [![PyPI - Django Version](https://img.shields.io/pypi/djversions/django-sass)](https://pypi.org/project/django-sass/) [![PyPI - Wheel](https://img.shields.io/pypi/wheel/django-sass)](https://pypi.org/project/django-sass/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/django-sass)](https://pypi.org/project/django-sass/) [![PyPI](https://img.shields.io/pypi/v/django-sass)](https://pypi.org/project/django-sass/) |\n| Build                  | [![Build Status](https://dev.azure.com/coderedcorp/cr-github/_apis/build/status/django-sass?branchName=main)](https://dev.azure.com/coderedcorp/cr-github/_build/latest?definitionId=10\u0026branchName=main) [![Azure DevOps tests (branch)](https://img.shields.io/azure-devops/tests/coderedcorp/cr-github/10/main)](https://dev.azure.com/coderedcorp/cr-github/_build/latest?definitionId=10\u0026branchName=main) [![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/coderedcorp/cr-github/10/main)](https://dev.azure.com/coderedcorp/cr-github/_build/latest?definitionId=10\u0026branchName=main) |\n\n\nInstallation\n------------\n\n1. Install from pip.\n\n```\npip install django-sass\n```\n\n2. Add to your `INSTALLED_APPS` (you only need to do this in a dev environment,\nyou would not want this in your production settings file, although it adds zero\noverhead):\n\n```python\nINSTALLED_APPS = [\n    ...,\n    'django_sass',\n]\n```\n\n3. Congratulations, you're done 😀\n\n\nUsage\n-----\n\nIn your app's static files, use Sass as normal. The only difference is that\nyou can **not** traverse upwards using `../` in `@import` statements. For example:\n\n```\napp1/\n|- static/\n   |- app1/\n      |- scss/\n         |- _colors.scss\n         |- app1.scss\napp2/\n|- static/\n   |- app2/\n      |- scss/\n         |- _colors.scss\n         |- app2.scss\n```\n\nIn `app2.scss` you could reference app1's and app2's `_colors.scss` import as so:\n\n```scss\n@import 'app1/scss/colors';\n@import 'app2/scss/colors';\n// Or since you are in app2, you can reference its colors with a relative path.\n@import 'colors';\n```\n\nThen to compile `app2.scss` and put it in the `css` directory,\nrun the following management command (the `-g` will build a source map, which\nis helpful for debugging CSS):\n\n```\npython manage.py sass app2/static/app2/scss/app2.scss app2/static/app2/css/app2.css -g\n```\n\nOr, you can compile the entire `scss` directory into\na corresponding `css` directory. This will traverse all subdirectories as well:\n\n```\npython manage.py sass app2/static/app2/scss/ app2/static/app2/css/\n```\n\nIn your Django HTML template, reference the CSS file as normal:\n\n```html\n{% load static %}\n\u003clink href=\"{% static 'app2/css/app2.css' %}\" rel=\"stylesheet\"\u003e\n```\n\n✨✨ **Congratulations, you are now a Django + Sass developer!** ✨✨\n\nNow you can commit those CSS files to version control, or run `collectstatic`\nand deploy them as normal.\n\nFor an example project layout, see `testproject/` in this repository.\n\n\nWatch Mode\n----------\n\nTo have `django-sass` watch files and recompile them as they change (useful in\ndevelopment), add the ``--watch`` flag.\n\n```\npython manage.py sass app2/static/app2/scss/ app2/static/app2/css/ --watch\n```\n\n\nExample: deploying compressed CSS to production\n-----------------------------------------------\n\nTo compile minified CSS, use the `-t` flag to specify compression level (one of:\n\"expanded\", \"nested\", \"compact\", \"compressed\"). The default is \"expanded\" which\nis human-readable.\n\n```\npython manage.py sass app2/static/app2/scss/ app2/static/app2/css/ -t compressed\n```\n\nYou may now optionally commit the CSS files to version control if so desired,\nor omit them, whatever fits your needs better. Then run `collectsatic` as normal.\n\n```\npython manage.py collectstatic\n```\n\nAnd now proceed with deploying your files as normal.\n\n\nLimitations\n-----------\n\n* `@import` statements must reference a path relative to a path in\n  `STATICFILES_FINDERS` (which will usually be an app's `static/` directory or\n  some other directory specified in `STATICFILES_DIRS`). Or they can reference a\n  relative path equal to or below the current file. It does not support\n  traversing up the filesystem (i.e. `../`).\n\n  Legal imports:\n  ```scss\n  @import 'file-from-currdir';\n  @import 'subdir/file';\n  @import 'another-app/file';\n  ```\n  Illegal imports:\n  ```scss\n  @import '../file';\n  ```\n\n* Only supports `-g`, `-p`, and `-t` options similar to `pysassc`. Ideally\n  `django-sass` will be as similar as possible to the `pysassc` command line\n  interface.\n\nFeel free to file an issue or make a pull request to improve any of these\nlimitations. 🐱‍💻\n\n\nWhy django-sass?\n----------------\n\nOther packages such as\n[django-libsass](https://github.com/torchbox/django-libsass) and\n[django-sass-processor](https://github.com/jrief/django-sass-processor), while\nnice packages, require `django-compressor` which itself depends on several other\npackages that require compilation to install.\n\nInstalling `django-compressor` in your production web server requires a LOT of\nextra bloat including a C compiler. It then will compile the Sass on-the-fly\nwhile rendering the HTML templates. This is a wasteful use of CPU on your web\nserver.\n\nInstead, `django-sass` lets you compile the Sass locally on your machine\n*before* deploying, to reduce dependencies and CPU time on your production web\nserver. This helps keep things fast and simple.\n\n* If you simply want to use Sass in development without installing a web of\n  unwanted dependencies, then `django-sass` is for you.\n* If you don't want to deploy any processors or compressors to your production\n  server, then `django-sass` is for you.\n* If you don't want to change the way you reference and serve static files,\n  then `django-sass` is for you.\n* And if you want the absolute simplest installation and setup possible for\n  doing Sass, `django-sass` is for you too.\n\ndjango-sass only depends on libsass (which provides pre-built wheels for\nWindows, Mac, and Linux), and of course Django (any version).\n\n\nProgrammatically Compiling Sass\n-------------------------------\n\nYou can also use `django-sass` in Python to programmatically compile the sass.\nThis is useful for build scripts and static site generators.\n\n```python\nfrom django_sass import compile_sass\n\n# Compile scss and write to output file.\ncompile_sass(\n    inpath=\"/path/to/file.scss\",\n    outpath=\"/path/to/output.css\",\n    output_style=\"compressed\",\n    precision=8,\n    source_map=True\n)\n```\n\nFor more advanced usage, you can specify additional sass search paths outside\nof your Django project by using the `include_paths` argument.\n\n```python\nfrom django_sass import compile_sass, find_static_paths\n\n# Get Django's static paths.\ndirs = find_static_paths()\n\n# Add external paths.\ndirs.append(\"/external/path/\")\n\n# Compile scss and write to output file.\ncompile_sass(\n    inpath=\"/path/to/file.scss\",\n    outpath=\"/path/to/output.css\",\n    output_style=\"compressed\",\n    precision=8,\n    source_map=True,\n    include_paths=dirs,\n)\n```\n\nContributing\n------------\n\nTo set up a development environment, first check out this repository, create a\nvenv, then:\n\n```\n(myvenv)$ pip install -r requirements-dev.txt\n```\n\nBefore committing, run static analysis tools:\n\n```\n(myvenv)$ black .\n(myvenv)$ flake8\n(myvenv)$ mypy\n```\n\nThen run the unit tests:\n\n```\n(myvenv)$ pytest\n```\n\n\nChangelog\n---------\n\n#### 1.1.0\n* New: Now compiles `.sass` files as well as `.scss` files.\n* Fix bug when input path is a file and output path does not exist.\n\n#### 1.0.1\n* Maintanence release, no functional changes.\n* Add additional type hints within the codebase.\n* Tested against Django 3.1\n* Formatted code with `black`.\n\n#### 1.0.0\n* New: You can now use `django_sass` APIs directly in Python.\n* Added unit tests.\n* Code quality improvements.\n\n#### 0.2.0\n* New feature: `-g` option to build a source map (when input is a file, not a\n  directory).\n\n#### 0.1.2\n* Fix: Write compiled CSS files as UTF-8.\n* Change: Default `-p` precision from 5 to 8 for better support building\n  Bootstrap CSS.\n\n#### 0.1.1\n* Fix: Create full file path if not exists when specifying a file output.\n\n#### 0.1.0\n* Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderedcorp%2Fdjango-sass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderedcorp%2Fdjango-sass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderedcorp%2Fdjango-sass/lists"}