On Tue, Jul 15, 2008 at 1:22 PM, Torsten Bronger <[EMAIL PROTECTED]> wrote: > Arien writes: >> You'll have to make layer._meta.verbose_name available to the >> template under some other name. > > Unfortunately, I use model polymorphism and model inheritance in > this case and can't pass anything but the common base class to the > template.
How about sticking this on the base class then? @property def verbose_name(self): return self._meta.verbose_name > Therefore, I collect all verbose_names in an "all_labels" dict in my > models.py: > > all_labels = {} > for cls in [cls for cls in _globals.values() if inspect.isclass(cls) and > issubclass(cls, models.Model)]: > local_labels = {} > for field in cls._meta.local_fields: > local_labels[field.name] = field.verbose_name > all_labels[cls.__name__] = local_labels 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 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 -~----------~----~----~----~------~----~------~--~---