A Django project made to easier integrate Tailwind.
Project description
Dj-tailwind
Dj-tailwind is a Django app that allows you to quickly add Tailwind to your project. It's a simple way to get started with Tailwind CSS in Django. The setup is minimal, and you can start using Tailwind in your project in minutes.
Features:
- Uses cookiecutter to initialize an empty Tailwind project.
- Adds commands for building, updating and watching and Tailwind.
- Provides template tags for including Tailwind CSS in your templates.
- Provides settings to configure the initial Tailwind build.
Installation
Install dj-tailwind with pip:
pip install dj-tailwind`
Add the app and dependencies to installed Django applications:
INSTALLED_APPS = [
...
"dj-tailwind",
...
]
Optional: set the Tailwind configuration in your settings file:
DJ_TAILWIND_APP_NAME = "tailwind" # The name of the app that will be created, defaults to `dj_tailwind_output`
DJ_TAILWIND_ENABLE_DAISYUI = True # Enable daisyUI
Run the init command to create the Tailwind project:
python manage.py dj_tailwind init
The preceding command generates a Django app called dj_tailwind_output which contains the Tailwind project. The folder is located in the root of your Django project.
Add the generated app to your installed apps:
INSTALLED_APPS = [
...
"dj_tailwind_output",
...
]
Add the Tailwind CSS to your base template:
{% load tailwind_tags %}
<head>
{% dj_tailwind_css %}
</head>
Run the start command to start the Tailwind project in watch mode:
python manage.py dj_tailwind start
Customization
Dj-tailwind uses the default Tailwind configuration file and optionally adds the daisyUI plugin. To not introduce complexity and leave customization to end users, you're expected to customize the Tailwind configuration by editing the tailwind.input.css file in the dj_tailwind_output app. An example configuration file custom fonts and themes:
@import 'tailwindcss' source('../');
@plugin "@tailwindcss/typography";
@plugin "@tailwindcss/forms";
@plugin "@tailwindcss/aspect-ratio";
@plugin "daisyui" {
themes: dark, light;
}
@plugin "daisyui/theme" {
name: 'dark';
prefersdark: true;
--color-primary: oklch(70% 0.165 254.624);
--color-primary-content: oklch(98% 0.001 106.423);
}
@plugin "daisyui/theme" {
name: 'light';
default: true;
--color-primary: oklch(54% 0.245 262.881);
--color-primary-content: oklch(98% 0.001 106.423);
}
@theme {
--font-sans: Inter var;
}
Production Builds
To build the Tailwind project for production, run the build command:
./manage.py tailwind install
./manage.py tailwind build
./manage.py collectstatic --no-input
Commands
Dj-tailwind provides several commands to manage the Tailwind project:
./manage.py dj_tailwind init- Initializes the Tailwind project../manage.py dj_tailwind build- Builds the Tailwind project../manage.py dj_tailwind start- Starts the Tailwind project in watch mode../manage.py dj_tailwind update- Updates the NPM dependencies.
Alternatives
- Django-tailwind - similar project but it hasn't been updated in a while. This project is fairly similar but this is up to date and more lightweight.
- Django-tailwind-cli - uses the precompiled Tailwind command-line tool, no dependency on Node. However, custom theming seems more complex.
Migrating from Django-tailwind
If you're using the django-tailwind package, you can migrate to dj-tailwind by following these steps:
- Remove the
themeapp directory from your project and thedjango_tailwindapp from your installed apps. - If you've added custom Tailwind configuration, you can copy it to the new
dj_tailwind_outputapp. Tailwind 4.0 doesn't supporttailwind.config.jsfiles, so you'll need to use thetailwind.input.cssfile instead. - Dj-tailwind uses Tailwind 4.0, which has breaking changes. You'll need to update your templates to use the new Tailwind classes. Read more here.
- Follow the installation instructions to install
dj-tailwindand initialize the Tailwind project. - The commands are prefixed with
dj_tailwindinstead oftailwind.
Project details
Release history Release notifications | RSS feed
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 dj_tailwind-0.2.0.tar.gz.
File metadata
- Download URL: dj_tailwind-0.2.0.tar.gz
- Upload date:
- Size: 67.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01893e959722f89edd6421128ab18d91b24553b8d4af341bd1a60b5d33a2eae4
|
|
| MD5 |
2ce687c3319fe748739581b439efe4cf
|
|
| BLAKE2b-256 |
45b9111df1db96aa1765317f793e551aabea51cb797789820c31a5897523162f
|
Provenance
The following attestation bundles were made for dj_tailwind-0.2.0.tar.gz:
Publisher:
ci-cd.yml on adinhodovic/dj-tailwind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dj_tailwind-0.2.0.tar.gz -
Subject digest:
01893e959722f89edd6421128ab18d91b24553b8d4af341bd1a60b5d33a2eae4 - Sigstore transparency entry: 937372222
- Sigstore integration time:
-
Permalink:
adinhodovic/dj-tailwind@79a7e9281b26dcc8e0e08574688549949dfb7e96 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/adinhodovic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@79a7e9281b26dcc8e0e08574688549949dfb7e96 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dj_tailwind-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dj_tailwind-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24b45a8aa2412b165484a136a5cc1a10e83c91c5ce0bdb03de3219debde5e9d5
|
|
| MD5 |
4d4ad76a5249186f5413041d4646474a
|
|
| BLAKE2b-256 |
0d32921bd014605fd1e2eb6c0f4d365cf6bbad18ce346f1ea65b6292bef903b0
|
Provenance
The following attestation bundles were made for dj_tailwind-0.2.0-py3-none-any.whl:
Publisher:
ci-cd.yml on adinhodovic/dj-tailwind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dj_tailwind-0.2.0-py3-none-any.whl -
Subject digest:
24b45a8aa2412b165484a136a5cc1a10e83c91c5ce0bdb03de3219debde5e9d5 - Sigstore transparency entry: 937372251
- Sigstore integration time:
-
Permalink:
adinhodovic/dj-tailwind@79a7e9281b26dcc8e0e08574688549949dfb7e96 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/adinhodovic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci-cd.yml@79a7e9281b26dcc8e0e08574688549949dfb7e96 -
Trigger Event:
release
-
Statement type: