The quickest way to get started with Tailwind in CSS is by using
Django tailwind.
We'll walk you through the Django-tailwind setup.
First, you need to install the django-tailwind package. You can do this using pip
pip install django-tailwind
Then add django-tailwind to INSTALLED_APPS in settings.py
INSTALLED_APPS = [
...
'tailwind',
...
]
Now create a tailwind app
python manage.py tailwind init <tailwind_app_name>
Now add that app to INSTALLED_APPS
INSTALLED_APPS = [
# other Django apps
'tailwind',
'tailwind_app_name'
]
Now go ahead and register the app by adding the following in settings.py
TAILWIND_APP_NAME='<tailwind_app_name>'
By default Django tailwind includes a base.html file, if you are not using that base.html file, you can delete it and add the following to your custom base.html
{% load static tailwind_tags %}
...
<head>
...
{% tailwind_css %} <!-- this adds the css stylesheet -->
...
</head>
Now that's done, lets start our tailwind by using the following command
python manage.py tailwind start
For production build use
python manage.py tailwind build
That's it you can now start using Tailwind in Django. If you want to read advanced usage, check out their docs
Top comments (0)