Set Up Tailwind CSS and DaisyUI in Django with django-tailwind

In progress Django

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 in core/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 dev and the DaisyUI option arrived in 4.2.0 (July 2025).

Steps

  1. 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]'
    
  2. Create the theme app. Answer theme for the name, pick the npm-based (full) Tailwind v4 install, and accept DaisyUI.
    uv run python manage.py tailwind init
    
  3. Register the apps and name the theme app:
    # core/settings.py
    INSTALLED_APPS += ["tailwind", "theme"]
    TAILWIND_APP_NAME = "theme"
    
  4. 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"))]
    
  5. Install the npm dependencies of the theme app:
    uv run python manage.py tailwind install
    
  6. Load the stylesheet in the base template's <head>:
    {% load tailwind_tags %}
    <head>
      ...
      {% tailwind_css %}
    </head>
    
  7. Start Django and the Tailwind watcher together:
    uv run python manage.py tailwind dev
    
  8. 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.
  • npm not found: set NPM_BIN_PATH in settings to the full path of npm (on Windows, npm.cmd).
  • No reload on save: check the middleware sits after response-encoding middleware such as GZipMiddleware.

References