Registry / web-framework / crispy-tailwind

crispy-tailwind

JSON →
library1.0.3pypypi✓ verified 87d ago

crispy-tailwind provides a Tailwind CSS template pack for Django Crispy Forms, allowing developers to easily render forms with Tailwind's utility-first classes. It is currently at version 1.0.3 and has a moderately active release cadence, with frequent bug-fix releases and major versions adding support for newer Django and Python versions.

pip install crispy-tailwind
INSTALL
IMPORT
SIG · CRISPY-TAILWIND
C
crispy-tailwind
web-frameworkpythonv1.0.3
Install
3.6s avg
Import
680ms
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.712s · 66.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.6s · import 0.648s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FormHelper
from crispy_forms.helper import FormHelper
Used in forms.py to customize form rendering.
Layout
from crispy_forms.layout import Layout, Submit
Used in forms.py to define custom form layouts.

After installing, add 'crispy_forms' and 'crispy_tailwind' to your `INSTALLED_APPS` in `settings.py`. Crucially, set `CRISPY_ALLOWED_TEMPLATE_PACKS = "tailwind"` and `CRISPY_TEMPLATE_PACK = "tailwind"`. Then, in your Django forms, instantiate a `FormHelper` and define your layout. Finally, render the form in your template using `{% load crispy_forms_tags %}` and `{% crispy form %}`.

# settings.py INSTALLED_APPS = [ # ... 'crispy_forms', 'crispy_tailwind', # ... ] CRISPY_ALLOWED_TEMPLATE_PACKS = "tailwind" CRISPY_TEMPLATE_PACK = "tailwind" # forms.py from django import forms from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Submit class ContactForm(forms.Form): name = forms.CharField(label='Your Name', max_length=100) email = forms.EmailField(label='Your Email') message = forms.CharField(label='Your Message', widget=forms.Textarea) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( 'name', 'email', 'message', Submit('submit', 'Send', css_class='btn-primary mt-4') ) # template.html (e.g., in a Django view) # {% load crispy_forms_tags %} # <form method="post"> # {% csrf_token %} # {% crispy form %} # </form>
Debug
Known issues
breakingCrispy-tailwind 1.0.0 introduced significant breaking changes, dropping support for older Django and Python versions and requiring an updated `django-crispy-forms`.
fix
Upgrade your Django project to Django >=4.2 and Python >=3.8. Also, ensure `django-crispy-forms` is at least version 2.0.0. Review the release notes for `crispy-tailwind 1.0.0` for full details.
affects: <1.0.0
gotchaThe `crispy_tailwind` application must be listed in `INSTALLED_APPS` *after* `crispy_forms` to ensure its templates correctly override the base ones.
fix
Ensure `INSTALLED_APPS` in `settings.py` is configured as: `['crispy_forms', 'crispy_tailwind', ...]`. The order matters for template loading.
affects: All
gotchacrispy-tailwind only provides the HTML structure with Tailwind CSS classes; it does not include or manage the Tailwind CSS framework itself. Your Django project must still be set up to compile and serve Tailwind CSS.
fix
Refer to the official Tailwind CSS documentation and your Django project's setup guide to correctly integrate and build Tailwind CSS (e.g., via PostCSS, CDN, or Tailwind CLI) for your frontend.
affects: All
gotchaForgetting to set `CRISPY_TEMPLATE_PACK = "tailwind"` or setting `CRISPY_ALLOWED_TEMPLATE_PACKS` incorrectly will result in forms rendering with default (usually Bootstrap-like) styles or template errors.
fix
In your `settings.py`, ensure you have both `CRISPY_ALLOWED_TEMPLATE_PACKS = "tailwind"` and `CRISPY_TEMPLATE_PACK = "tailwind"` defined.
affects: All
Errors
Common errors & fixes
ImproperlyConfigured: 'tailwind' isn't an allowed template pack.
The `CRISPY_ALLOWED_TEMPLATE_PACKS` setting is missing or does not include 'tailwind', or `crispy_tailwind` is not in `INSTALLED_APPS`.
fix
Add `CRISPY_ALLOWED_TEMPLATE_PACKS = "tailwind"` to `settings.py`. Also, ensure `crispy_tailwind` is included in `INSTALLED_APPS` (after `crispy_forms`).
TemplateDoesNotExist at /my-form/ crispy_forms/whole_uni_form.html
Django Crispy Forms is looking for its default template pack's files, indicating crispy-tailwind's templates are not being found or recognized.
fix
Verify that both `crispy_forms` and `crispy_tailwind` are in your `INSTALLED_APPS` in `settings.py` (in that order), and that `CRISPY_TEMPLATE_PACK = "tailwind"` is correctly set.
Forms render without Tailwind styles (plain HTML).
This usually means the Tailwind CSS framework itself is not correctly integrated into your Django project, or the `CRISPY_TEMPLATE_PACK` is not correctly set to 'tailwind'.
fix
Ensure `CRISPY_TEMPLATE_PACK = "tailwind"` is set in `settings.py`. Crucially, confirm that Tailwind CSS is properly built, included, and available in your frontend assets for your Django templates.
NameError: name 'FormHelper' is not defined
`FormHelper` class was used in a `forms.py` file without being imported.
fix
Add `from crispy_forms.helper import FormHelper` to the top of your `forms.py` file where `FormHelper` is used.
Upgrade
Version history
1.0.3latest on PyPI · released Feb 13, 2024
Audit
Dependencies
DjangorequiredRequired for any Django project. Version 1.0.0+ requires Django >=4.2.
django-crispy-formsrequiredcrispy-tailwind is a template pack for django-crispy-forms. Version 1.0.0+ requires django-crispy-forms >=2.0.
Agent activity
2 hits · last 30 days
node
2
Resources
crispy-tailwind — pip install crispy-tailwind · libregistry