django-tailwind-cli
Tailwind CSS for Django without Node.js. The library downloads the standalone Tailwind CSS CLI and wires it into Django management commands, so there is no npm, no webpack, and no separate build tool to configure. It follows the approach of the Tailwind integration for Phoenix.
What it does
- Downloads and manages the Tailwind CLI binary for your platform
- Rebuilds CSS on change, running under Django's own auto-reloader
- Produces minified production builds containing only the classes you use, and skips work when nothing changed
- Includes the CSS via a
{% tailwind_css %}template tag - Supports DaisyUI through tailwindcss-cli-extra
- Targets Tailwind CSS 4.x
Installation
1. Install the package
# Using pip
pip install django-tailwind-cli
# Using uv
uv add django-tailwind-cli
# Using poetry
poetry add django-tailwind-cli
2. Configure Django settings
Add to your settings.py:
INSTALLED_APPS = [
# ... your other apps
"django_tailwind_cli",
]
# Configure static files directory — make sure it exists on disk,
# Django raises an error at startup if it does not.
STATICFILES_DIRS = [BASE_DIR / "assets"]
mkdir -p assets
3. Set up your base template
Create or update your base template (e.g. templates/base.html):
<!DOCTYPE html>
{% load tailwind_cli %}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Django App</title>
{% tailwind_css %}
</head>
<body class="bg-gray-50">
<div class="container mx-auto px-4">
{% block content %}{% endblock %}
</div>
</body>
</html>
4. Start developing
# Start Django's dev server with a parallel Tailwind watcher
python manage.py tailwind runserver
# Or run build and watch separately
python manage.py tailwind watch # In one terminal
python manage.py runserver # In another terminal
The watcher runs under Django's own auto-reloader, so editing settings.py (e.g. adding a new app)
restarts it automatically and picks up the new configuration on the fly. Pass --noreload to opt
out.
First run creates a managed <BASE_DIR>/.django_tailwind_cli/ directory for the CLI binary and an
auto-generated source.css. The directory is automatically git-ignored — no entry in your
project-level .gitignore needed.
python manage.py tailwind setup walks the same ground: it checks each piece in order, stops at
the first one that is missing with instructions, and performs the download and first build when
they are needed.
Management commands
| Command | Purpose | Example |
|---|---|---|
setup |
Guided first-time setup and checks | python manage.py tailwind setup |
build |
Production CSS build | python manage.py tailwind build |
watch |
Development file watcher (Django autoreload by default) | python manage.py tailwind watch |
runserver |
Django dev server + watcher (forwards any runserver flag) | python manage.py tailwind runserver |
config |
Show current configuration | python manage.py tailwind config |
troubleshoot |
Debug common issues | python manage.py tailwind troubleshoot |
build takes --force to rebuild regardless of change detection; build and watch both take
--verbose for detailed diagnostics.
tailwind runserver is a transparent passthrough: every positional argument and option (apart from
--force-default-runserver) is forwarded verbatim to the underlying runserver or
runserver_plus. Every flag those commands accept works — including runserver_plus-only ones like
--extra-file, --reloader-interval, and --print-sql.
Requirements
- Python: 3.10+
- Django: 4.2 LTS, 5.2, 6.0, or 6.1
- Platform: Windows, macOS, Linux (automatic platform detection)
Configuration
Beyond adding the app to INSTALLED_APPS, STATICFILES_DIRS is the only setting you have to
configure. Everything below is optional; see the
settings reference for the full
list.
# Pin a specific Tailwind version instead of tracking the latest release
TAILWIND_CLI_VERSION = "4.1.3"
# Custom CSS paths
TAILWIND_CLI_SRC_CSS = "src/styles/main.css"
TAILWIND_CLI_DIST_CSS = "css/app.css"
# Enable DaisyUI
TAILWIND_CLI_USE_DAISY_UI = True
# Use an already-installed Tailwind binary (e.g. `brew install tailwindcss`)
TAILWIND_CLI_USE_SYSTEM_BINARY = True
# Auto-inject @source directives for editable-installed external apps (opt-in)
TAILWIND_CLI_AUTO_SOURCE_EXTERNAL_APPS = True
For production, pin the version and provide the binary yourself rather than downloading it during a build:
TAILWIND_CLI_VERSION = "4.1.3"
TAILWIND_CLI_AUTOMATIC_DOWNLOAD = False
TAILWIND_CLI_PATH = "/usr/local/bin/tailwindcss" # where your binary actually is
TAILWIND_CLI_DIST_CSS = "css/tailwind.min.css"
DaisyUI
Setting TAILWIND_CLI_USE_DAISY_UI = True switches to the DaisyUI-enabled CLI build, which makes
its component classes available:
<button class="btn btn-primary">Primary Button</button>
<div class="card bg-base-100 shadow-xl">
<div class="card-body">
<h2 class="card-title">Card Title</h2>
<p>Card content goes here.</p>
</div>
</div>
Troubleshooting
CSS not updating?
python manage.py tailwind build --force
python manage.py tailwind troubleshoot
Configuration problems?
python manage.py tailwind config
python manage.py tailwind setup
Classes from some templates are missing?
Make sure every template directory is covered by an @source directive in your Tailwind CSS input
file — Tailwind CSS 4.x discovers templates exclusively through those directives. Declaring them
explicitly also keeps builds fast, because Tailwind only scans what you list.
Documentation and related projects
- Full documentation
- Tailwind CSS documentation
- DaisyUI components
- tailwindcss-cli-extra — the DaisyUI-enabled CLI build
- Django Extensions — provides
runserver_plus - Tailwind CSS IntelliSense — VS Code extension
- Django Commons
Contributing
Contributions are welcome.
Prerequisites
- mise — provisions Python 3.10–3.15,
uv, andpre-commitfrommise.toml
Development setup
git clone https://github.com/django-commons/django-tailwind-cli.git
cd django-tailwind-cli
mise install
mise run bootstrap
Development commands
mise run upgrade # Update dependencies
mise run lint # Run linting and formatting
mise run test # Run test suite
mise run test-all # Run tests across Python/Django versions
Guidelines
Fork the repository and work on a feature branch. Please add type hints and tests for new code,
update the documentation for user-facing changes, and use
conventional commits (feat:, fix:, docs:, …) so the
history stays readable. Run mise run test before opening a pull request.
License
This software is licensed under MIT license.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_tailwind_cli-4.7.0.tar.gz.
File metadata
- Download URL: django_tailwind_cli-4.7.0.tar.gz
- Upload date:
- Size: 125.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e037b892b643a6e4d1d657276018650c0509000cae45af9107a4f7c93e4f3fd
|
|
| MD5 |
4e3dc2e4f82e8bfb827c3afa600b15ab
|
|
| BLAKE2b-256 |
5a0efb33781ec9196e6073696064aea86ffe5876ffaac89628ee3f52fe1ea93b
|
Provenance
The following attestation bundles were made for django_tailwind_cli-4.7.0.tar.gz:
Publisher:
release.yml on django-commons/django-tailwind-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tailwind_cli-4.7.0.tar.gz -
Subject digest:
9e037b892b643a6e4d1d657276018650c0509000cae45af9107a4f7c93e4f3fd - Sigstore transparency entry: 2475996774
- Sigstore integration time:
-
Permalink:
django-commons/django-tailwind-cli@0769c5256d1e4f37866d1a5784228dec349df357 -
Branch / Tag:
refs/tags/v4.7.0 - Owner: https://github.com/django-commons
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0769c5256d1e4f37866d1a5784228dec349df357 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_tailwind_cli-4.7.0-py3-none-any.whl.
File metadata
- Download URL: django_tailwind_cli-4.7.0-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dada508ced422734366cfa5175cb4738ec942e7fd791383e9470ce1a5748cba
|
|
| MD5 |
ce52cf73ba8806e88551a680e7c9a077
|
|
| BLAKE2b-256 |
53c7a5872353e434add9cdfdba04032a175cb1e2fbe752d05d77ddfebd466447
|
Provenance
The following attestation bundles were made for django_tailwind_cli-4.7.0-py3-none-any.whl:
Publisher:
release.yml on django-commons/django-tailwind-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tailwind_cli-4.7.0-py3-none-any.whl -
Subject digest:
7dada508ced422734366cfa5175cb4738ec942e7fd791383e9470ce1a5748cba - Sigstore transparency entry: 2475997310
- Sigstore integration time:
-
Permalink:
django-commons/django-tailwind-cli@0769c5256d1e4f37866d1a5784228dec349df357 -
Branch / Tag:
refs/tags/v4.7.0 - Owner: https://github.com/django-commons
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0769c5256d1e4f37866d1a5784228dec349df357 -
Trigger Event:
push
-
Statement type: