Add CSS class template filter

Sometimes you want to add CSS classes to HTML elements that are generated by Django using their __unicode__ representation, eg. you can output a form field with {{ form.name }}, but if you would like to add a certain CSS class to the outputted input or select tag you would have to assort to plain HTML.

Using this filter you can simply do something like {{ form.name|add_class:"span-4" }} which will render an input like <input type="..." name="..." class="span-4.