See if this tag won't work for you: class ObjectAttribNode(template.Node): def __init__(self, obj, attr): self.obj = obj self.attr = attr
def render(self, context): print self.attr try: obj = resolve_variable(self.obj, context) attr = resolve_variable(self.attr, context) return str(getattr(obj,attr,'')) except template.VariableDoesNotExist: return '' def do_val_by_object_attrib(parser, token): try: # split_contents() knows not to split quoted strings. tag_name, obj, attr = token.split_contents() except ValueError: raise template.TemplateSyntaxError, "%r tag requires exactly two arguments" % token.contents.split()[0] return ObjectAttribNode(obj, attr) register.tag('val_by_object_attrib', do_val_by_object_attrib) Then in template: {% val_by_object_attrib object attribute_name %} where object, and attribute_name are both variables in the context --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---