Crispy-formsCrispy-forms is a popular Python package for Django forms. Design, style, adjustments, custom rendering, and so on. Easy to install, easy to use. Crispy provides a more elegant appearance to the default form design.


Install Crispy-forms

Install Django crispy-forms into your project folder!

https://django-crispy-forms.readthedocs.io/en/latest/

Open your command-line interface or shell!

$ cd /set-your-path/

$ pipenv install django-crispy-forms

config/settings.py
INSTALLED_APPS = [ ... , 'crispy_forms', ] CRISPY_TEMPLATE_PACK = 'bootstrap4'

Using crispy in templates

any html template file

Loading crispy_forms_tags can be accessed by the Django template system. This is usually at the top of the html files. You can find examples in the chapter about authetication.

{% load crispy_forms_tags %}
any html template file

This template makes "crispy" the form which is rendered in one of the functions of views as a context dictionary.

{{ form|crispy }}

Crispy FormHelper

With Crispy forms, you are able to add more design to your forms. You can arrange the positions of the fields, change the colors, styles, attributes and so on.

https://django-crispy-forms.readthedocs.io/en/latest/form_helper...

I would like to illustrate now how Crispy could be more helpful.

models.py

This is just a random model to represent a simple model with two character field "name" and "email".

forms.py

This is a random form based on the upper model-form's fields. It is also a representation of how to arrange two form fields in one row, enhanced with some margin adjustments by Bootstrap.