We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
DjangoCon Europe 2023 | Good form: How Django’s form rendering improved during the 4.x series
Improve your form rendering in Django with the latest features and best practices, including use of field sets, templates, and third-party packages like Crispy Forms.
- Django 4.1 introduces use field set method for bound field template rendering.
- Field sets were added in Django 5.0 and replaced the old style legend tags.
- To ease transition, deprecated old style is still available.
- Crispy Forms is a third-party package that adds customization options for form rendering.
-
Template rendering has been improved, and it’s recommended to use
as_divinstead ofas_table. -
The
field orderattribute can be used to reorder fields on a form. - Custom form renderers can be created to define a template name and render the form.
- Bootstrap forms come with additional features, including custom layout objects and widget wrappers.
-
The
legendtag has been introduced in Django 4.1, which allows for more customization options. -
The
attrsdict on a widget can be used to define CSS classes. - Using third-party packages like Crispy Forms can be useful for adding additional features.
-
The
bound_fieldobject knows everything needed to render a field, including its label, errors, and help text. -
The
form renderercan be set to use a specific template, and this can be overridden on a per-form basis. -
The
bootstrap_templatepack comes with a template for rendering forms as HTML. -
The
bootstrap alertscomponent can be used to render alert messages in a form. -
The
bootstrap_floatcomponent can be used to make fields float to the right in a form. -
The
bootstrap_labelscomponent can be used to add custom labels to fields. -
The
bootstrap_notificationscomponent can be used to add notifications to forms. -
The
bootstrap_selectscomponent can be used to add selects (dropdowns) to forms.