Use class name in templates

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@register.filter
def classname(obj, arg=None):
    classname = obj.__class__.__name__.lower()
    if arg:
        if arg.lower() == classname:
            return True
        else:
            return False
    else:
        return classname

More like this

  1. Imagefield with variations by fivethreeo 3 years, 5 months ago
  2. Template loader to target a specific template by miracle2k 7 months ago
  3. Multiple-Submit-Button Widget for Choice Field by Archatas 3 years, 6 months ago
  4. Active class for navigation link by cschand 2 years, 4 months ago
  5. Human readable file names decorator by maxk 10 months, 2 weeks ago

Comments

(Forgotten your password?)