2

I work for the implementation of bootstrap 3 encountered a problem in the forms.

<form class="form-horizontal" action="" method="post">
    {% csrf_token %}

    {% for field in form %}
        <div class="form-group {% if field.errors %} error{% endif %}{% if field.required %} required{% endif %}">
            <label class="col-sm-2 control-label" for="{{ field.id_for_label }}">{{ field.label_tag }}</label>
                {{ field }}
                    {% for error in field.errors %}
                    <p class="help-block">{{ error }}</p>
                    {% endfor %}
        </div>
    {% endfor %}
</form>

input has no class = "form-control" so the form is not displayed correctly.enter image description here How to fix it?

wadadaaa
  • 309
  • 1
  • 4
  • 21

2 Answers2

1

Indeed this happens with default Django form widgets. You have the following possibilites in order of complexity:

The last one is kind of cumbersome but effective and you do not very much care if JS is disabled since this affects style and not functionality.

Community
  • 1
  • 1
Wtower
  • 18,848
  • 11
  • 103
  • 80
1

Look on django-crispy-forms http://django-crispy-forms.readthedocs.org/en/latest/install.html. It is easy way to integration django project with bootstrap 3

myarik
  • 31
  • 3