Snippet List
This 'smart_spaceless' template tag is a replacement for Django's built-in 'spaceless'. If settings.DEBUG = True, spaces will not be removed to make debugging your template code easier. When DEBUG = False, spaces will be removed.
Happy coding!
- template
- spaceless
- template tag
- remove spaces
- template tags
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`.
- django
- template tag
- css class
- template filter
3 snippets posted so far.