Login

Tag "trim"

Snippet List

really spaceless (trim spaces at line start)

This tag is meant to override the current implementation of '{% spaceless %}' tag and remove spaces at the beginning of a line too. I.e. a template like this: <div> <div>useless space up front</div> </div> will become this `<div>` `<div>useless space up front</div>` `</div>` All the other behaviour of spaceless stays the same! Put this in your app/name/templatetags/tags.py And if you want it to override the default "spaceless"-tag to the following from django.template import add_to_builtins add_to_builtins('app.name.templatetags.tags')

  • template
  • tag
  • trim
  • spaceless
Read More

Automatically trim newforms text fields

Makes sure the value a user entered into a a text-based field is automatically trimmed during form cleaning / validation. The 'field' parameter is expected to be a newforms.fields.Field _instance_.Only modifies str and unicode descending values, and passes everything else on untouched. Example: form = form_for_model(Person) make_trimming(form.fields['name'])

  • newforms
  • strings
  • trim
Read More

2 snippets posted so far.