DEV Community

Phansivang
Phansivang

Posted on

Django Crispy Form

terminal

> pip install django-crispy-forms
Enter fullscreen mode Exit fullscreen mode

setting.py

INSTALLED_APPS = [
    ...

    'crispy_forms',
]

CRISPY_TEMPLATE_PACK = 'bootstrap4'
Enter fullscreen mode Exit fullscreen mode

In your HTML form

example.html

{% load crispy_forms_tags %}

{% block content %}
  <form method="post">
    {% csrf_token %}
    {{ form|crispy }}
    <button type="submit" class="btn btn-primary">Sign in</button>
  </form>
{% endblock %}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)