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. Multiple-Submit-Button Widget for Choice Field by Archatas 5 years, 8 months ago
  2. Human readable file names decorator by maxk 3 years ago
  3. Generic model filter from request GET data by genbit 2 years, 8 months ago
  4. Imagefield with variations by fivethreeo 5 years, 8 months ago
  5. Subdirectory and subcontext include template tag with examples by t_rybik 4 years ago

Comments

(Forgotten your password?)