Set Up Tailwind CSS and DaisyUI in Django with django-tailwind
Goal
Style a Django project with Tailwind CSS utility classes and DaisyUI components, with the CSS rebuilt and the browser reloaded on every save during development.
Prerequisites
- A Django project managed with
uv(settings incore/settings.py). - Node.js for the npm-based install, e.g. through mise:
mise use node@<version>(prefer an LTS release). - django-tailwind 4.2 or later:
tailwind devand the DaisyUI option arrived in 4.2.0 (July 2025).
Steps
- Install the package with its development extras: cookiecutter scaffolds the theme app, honcho runs both servers, reload adds
django-browser-reload.uv add 'django-tailwind[cookiecutter,honcho,reload]' - Create the theme app. Answer
themefor the name, pick the npm-based (full) Tailwind v4 install, and accept DaisyUI.uv run python manage.py tailwind init - Register the apps and name the theme app:
# core/settings.py INSTALLED_APPS += ["tailwind", "theme"] TAILWIND_APP_NAME = "theme" - Enable browser reload in development only:
# core/settings.py if DEBUG: INSTALLED_APPS += ["django_browser_reload"] MIDDLEWARE += ["django_browser_reload.middleware.BrowserReloadMiddleware"] # core/urls.py if settings.DEBUG: urlpatterns += [path("__reload__/", include("django_browser_reload.urls"))] - Install the npm dependencies of the theme app:
uv run python manage.py tailwind install - Load the stylesheet in the base template's
<head>:{% load tailwind_tags %} <head> ... {% tailwind_css %} </head> - Start Django and the Tailwind watcher together:
uv run python manage.py tailwind dev - Add Makefile targets so the project starts the same way every time:
dev: cd django-app && uv run manage.py tailwind dev build: cd django-app && uv run manage.py tailwind build
Verify
- A page with
class="btn btn-primary"shows a styled DaisyUI button. - Editing a template or adding a class reloads the browser with the new style.
- With
DEBUG = False,/__reload__/returns 404.
Troubleshooting
- Classes have no effect: Tailwind only generates classes it finds in scanned files. Check the template lives where the theme app scans, and restart
tailwind dev. npmnot found: setNPM_BIN_PATHin settings to the full path ofnpm(on Windows,npm.cmd).- No reload on save: check the middleware sits after response-encoding middleware such as
GZipMiddleware.
References
- django-tailwind documentation: Installation - the extras,
init,install,devand the browser-reload setup. - django-tailwind just got better with a unified dev command and daisyUI - the author's 4.2.0 release post (July 2025, checked 2026-10-26).
- daisyUI documentation - the component classes (
btn,hero). - Multi-Stage Docker Builds for Frontend Assets and Static Collection - compiling the CSS in a production image.
- Django MOC - hub for Django notes.