6

I read several posts about which bootstrap package use (mainly Crispy-form VS django-toolkit-integration)

But I'm pretty new to Django and I still don't understand what is the real need about these packages. I mean, Twitter bootstrap is nothing more than css/js files. So, I thought using bootstrap by linking my Django forms and field to HTML classes (using widgets for .py forms, and directly in .html templates for other fields)

So, what are the benefits of these packages? Is it just convenience or am I really missing something if I choose to not use it?

Thank you for help!

girasquid
  • 15,121
  • 2
  • 48
  • 58
David Dahan
  • 10,576
  • 11
  • 64
  • 137
  • Could you share the posts links ? – John Wang Apr 08 '13 at 12:16
  • John, these are the 2 links : http://stackoverflow.com/questions/11821116/django-and-bootstrap-what-app-is-recommended http://stackoverflow.com/questions/11749860/how-to-render-django-forms-choicefield-as-twitter-bootstrap-dropdown – David Dahan Apr 08 '13 at 14:24

3 Answers3

4

It is just a convenience for forms. It provides you with template tags. Django provides two methods as_p, as_ul and as_table but none of them works smoothly with bootstrap. So you use something like instead.

{% extends 'base.html' %}
{% load crispy_forms_tags %}

{% block content %}
    {% form|crispy %}
{% endblock %}

It also provides some convenient classes to configure in the Django Forms.

So, it is not necessary but it will save you some hassles to configure forms. You can start without them and when the problems come, you will find them useful.

toto_tico
  • 17,977
  • 9
  • 97
  • 116
1

As you yourself said, Twitter Bootstrap are only CSS and JS files that you will apply in your HTML structure and get a new face of its elements. The Bootstrap provides a number of ready-made elements and styles.

Many websites come ready structures and even site templates ready using Bootstrap, as: Bootsnipp, Bootswatch, Wrapbootstrap and many others. The big advantage I see is not wasting time with styles (I'm not disparaging the designers) and focus more on programming.

My final note is: give a chance to the Twitter Bootstrap, it is very useful in creating models and styles faster, more focused on the end product.

Filipe Manuel
  • 967
  • 2
  • 14
  • 33
1

Some of this packages are made to be able to write your CSS in Less (the language), and compile them automatically. Also, some may add compression and concatenation of assets.

As Bootstrap is nothing more than a bunch of CSS and Javascript files (and I don't use Less) so far all I need is form integration, which is easily achieved by this:

NOTE: This is a very specific example of my own code, but you get the idea.

<div class="row">
    <div class="span6 offset3">

    <form id="form-history" class="form-horizontal text-center"
          action="/somepath/" method="post">
        <fieldset>
            <legend><h3>History</h3></legend>

    {% for field in form %}
        <div class="row">
            <div class="span3">{{ field.label }}</div>
            <div class="span3">{{ field }}</div>
        </div>
    {% endfor %}

        <div class="row pull-right">
            <button class="btn btn-primary btn-large" type="submit">
                <i class="icon-ok icon-white"></i> Find
            </button>
        </div>

        </fieldset>
    </form>
MGP
  • 2,981
  • 35
  • 34