Django and Bootstrap: What app is recommended? [closed]

Solution 1:

I used django-bootstrap-toolkit — as the author explains (with reference to other Django/Bootstrap integration apps)

"The approach to template tags and filters seemed right, but Bootstrap does so much more than just forms."

In addition to forms, then (which can be as simple as {% form|as_bootstrap %}, this app helps with pagination, inserting static URLs to the Bootstrap media files, and some other bits. Read templatetags/bootstrap-toolkit.py for the full list.

@dolan notes that the django-bootstrap-toolkit developer recommends a new project for Bootstrap v3 support, django-bootstrap3. I haven't tried this yet as I haven't started a new project since V3 came out, so YMMV.

Solution 2:

I've been using django-crispy-forms with bootstrap for the last couple of months and it has been quite useful. Forms render exactly as they're meant to. If you do any custom form rendering though, be prepared to define your forms in code rather than in template, using helpers.

Solution 3:

Another option to consider is django-bootstrap-form.

I found crispy-forms to be too heavyweight for my needs. Django-bootstrap is not maintained any more. I tried django-bootstrap-toolkit and django-bootstrap-form, and while it does look like django-bootstrap-toolkit has more features, I found my needs were met by django-bootstrap-form. In the interest of keeping things simple, I chose the latter, and haven't found it lacking (although I'd be interested to hear other opinions on their relative merits).

In addition to django-bootstrap-form, I'd recommend django-widget-tweaks, which allows you to add classes (and other attributes) to your forms using template filters, e.g.:

{{ form.field|add_class:"input-small" }}

This lets you use class-based formatting from Bootstrap while keeping the presentation logic in the template.