-
Install from this repository using
pip
:pip install https://github.com/andredelft/django-tailwind/tarball/master
-
Ensure you have
"django.contrib.staticfiles"
in yourINSTALLED_APPS
. -
In the project settings, add
django_tailwind
anddjango_browser_reload
toINSTALLED_APPS
:INSTALLED_APPS = [ ... "django_tailwind", "django_browser_reload", ]
-
Include the app URL’s in your root URLconf(s):
from django.urls import include, path urlpatterns = [ ..., path("__reload__/", include("django_browser_reload.urls")), ]
You can use another prefix if required.
-
Also in the project settings, add the middleware required for
django_browser_reload
middleware:MIDDLEWARE = [ ... "django_browser_reload.middleware.BrowserReloadMiddleware", ... ]
Make sure it's listed after any middleware that encodes the response. Cf. the
django_browser_reload
documentation. -
In the root folder of your project, initialize the Tailwind config file and CSS entrypoint using the management command:
python manage.py tailwind --init
-
Compile the output CSS file
python manage.py tailwind
The config file will be located in /tailwind.config.js
, the CSS entrypoint file in /static/src/styles.css
and the CSS output file in /static/dist/styles.css
. These paths can be configured in the settings file using the variables TAILWIND_CONFIG_PATH
, TAILWIND_STYLES_SRC_PATH
and TAILWIND_STYLES_DIST_PATH
respectively (pathblib.Path
objects are supported).