The crispy template tag renders a Django form through its configured FormHelper, Layout, and template pack. It is more flexible than the | crispy filter: instead of accepting a canned layout, it can control HTML IDs, CSS classes, the form action, and the HTTP method. section 13.3.2
A typical setup follows this path:
- Install crispy-bootstrap5, add "crispy_bootstrap5" to INSTALLED_APPS, and set CRISPY_ALLOWED_TEMPLATE_PACKS and CRISPY_TEMPLATE_PACK to "bootstrap5". section 13.3.2
- Add FormHelper and an associated Layout to the ModelForm so Python code describes how the form should render. section 13.3.2
- Pass the form object to the template tag, using the helper and template-pack defaults to produce the form HTML. section 13.3.2
- Adjust template-pack-specific options when needed, such as Bootstrap's error_text_inline setting. section 13.3.2
Choosing between the filter and tag
A quick form can use {{ form|crispy }}, which applies an opinionated layout with no further visual control. A customizable form uses {% crispy form %}; its FormHelper and Layout can define IDs, classes, action, method, and other supported attributes in Python rather than in the template. section 13.3.2 section 13.3.2
This arrangement also lets a view programmatically control form presentation while keeping templates small. Crispy Forms supplies ready-made HTML through template packs, avoiding the need to write every underlying form-field widget template. section 13.3.2
