On Tue, Jul 15, 2008 at 2:08 PM, Arien <[EMAIL PROTECTED]> wrote: > Oh, I see, you want the verbose_name of each field. I suppose you > could write a templatetag that you could use like this: > > <td>{% verbose_name layer.heating_temperature %}</td> > <td>{{ layer.heating_temperature }}</td> > > After parsing the templatetag's argument, you'd resolve the model > instance and insert this in the template: > > model_instance._meta.get_field(field_name).verbose_name
The basic idea (and only that): class VerboseNameNode(template.Node): def __init__(self, model, field): self.model, self.field = model, field def render(self, context): model = template.Variable(self.model).resolve(context) return model._meta.get_field(self.field).verbose_name def do_verbose_name(parser, token): tag_name, var = token.split_contents() model, field = var.split('.') return VerboseNameNode(model, field) Arien --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---