The crispy filter renders a Django form object with the installed django-crispy-forms template pack. It is a quick alternative to form.as_p: the pack supplies a canned layout and styling, so the form looks more polished without hand-writing its HTML. section 13.3.2
Set up the filter before using it in a template:
- Install the main package: python -m pip install django-crispy-forms. section 13.3.2
- Register "crispy_forms" in INSTALLED_APPS. section 13.3.2
- Install a template-pack package for the chosen UI toolkit. For Bootstrap 5, use crispy-bootstrap5, register "crispy_bootstrap5", and set CRISPY_ALLOWED_TEMPLATE_PACKS and CRISPY_TEMPLATE_PACK to "bootstrap5". section 13.3.2
Render a form with the filter
Inside a Django template, replace form.as_p with the filter expression: {{ form|crispy }}. Django passes the form object to crispy forms, which emits the template pack's default layout and styling. The trade-off is simplicity: the filter provides no control over the generated look. When detailed HTML control is needed, use the {% crispy %} tag with FormHelper and Layout instead. section 13.3.2 section 13.6
