Tuesday, August 4, 2015

Re: Accessing a field's verbose_name

I am sorry, it seems like I've made a cuple of typos....

The name of my method is indeed get_descr all the time, so that is not the source of the problem.

And the command that I have tested and that returns myapp.FicheService.phone isn't
self._meta.get_field("phone").verbose_name
but
self._meta.get_field("phone")

To be more precise, it is even :
unicode(self._meta.get_field("phone"))
since without unicode, it returns the following error (see image) :

So, to sum up the lines of code and their effect :
self._meta.get_field("phone").verbose_name
and
unicode(self._meta.get_field("phone").verbose_name)
both cancel the display of my whole string without raising any error

self._meta.get_field("phone")
generates the error in the image

unicode(self._meta.get_field("phone"))
returns the string : "myapp.FicheService.phone"

--
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+unsubscribe@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/a46cb96d-c204-4d42-ab2b-06090a686490%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment