On 6/11/2014 2:29 PM, Neto wrote:
How access verbose_name of a instance in template?
I have:
car = Car.objects.get(pk=1)
Try this in a script somewhere to see if it returns the verbose name
def get_verbose_name(obj, field):
return
obj.__class__()._meta.get_field_by_name('{0}'.format(field))[0].verbose_name
... and if so, you should be able to pass it into the template along
with other items
In my template:
{{ car.color.??? }} {{ car.color }}
I wanna print the verbose_name, i want to it:
Color: red
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/1eaa4aba-1fe0-49b4-a397-381047b4c72a%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/1eaa4aba-1fe0-49b4-a397-381047b4c72a%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/545B05C8.4030105%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.