Linux, OpenSource, Programming And Hacks

Oct 19, 2016

How to Install and use Django Crispy Forms

Oct 19, 2016
Crispy forms is a third party django app that makes styling forms really simple. It makes your forms look beautiful with almost no effort from your side. It supports different template packs like uni-form, foundation, bootstrap and bootstrap3 , that's what we will be using.

Setting it up is simple as well with these few steps that I have shown below

1. Install django-crispy-form package with pip (make sure you have pip installed)
pip install --upgrade django-crispy-forms

2. add it to Installed apps in your project's file

3. add this line in your file

Now, crispy forms is ready to be used.. let's see how.

4. Put these tags at the top of your html template file (but below extends tags, if any) where you want to use crispy forms.
{% load crispy_forms_tags %}

5. Finally, use with {{ form|crispy }} make your form look crispy!
<form method="post">
{% csrf_token %}
   {{ form|crispy }}
   <input class="btn btn-default" type="submit" value="Submit" />

No comments:

Post a Comment