django-crispy-forms
In Bookr, we are using the Bootstrap CSS framework. It provides styles that can be applied to forms using CSS classes. Since Django is independent of Bootstrap, when we use Django forms, it does not even know that we are using Bootstrap and so has no idea of what classes to apply to form widgets.
django-crispy-forms
acts as an intermediary between Django forms and Bootstrap forms. It can take a Django form and render it with the correct Bootstrap elements and classes. It not only supports Bootstrap but also other frameworks, such as Uni-Form and Foundation (although Foundation support must be added using a separate package, crispy-forms-foundation
).
Its installation and setup are quite simple. Once again, it is installed with pip3
:
pip3 install django-crispy-forms
Note
For Windows, you can use pip
instead of pip3
in the preceding command.
Then, there are just a couple of settings changes. First, add crispy_forms
to your INSTALLED_APPS
. Then, you...