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. Allow any view (probably a generic view) to accept POST variables into extra_context by orblivion 2 years, 6 months ago
  2. Convert CamelCase to lowercase_with_underscores by jdriscoll 5 years, 3 months ago
  3. ExprTag - Calculating python expression and saving the result to a variable by limodou 6 years, 2 months ago
  4. User group template tag by jdriscoll 5 years, 11 months ago
  5. Database cleanup by skyjur 2 years, 9 months ago

Comments

(Forgotten your password?)