in a Model I have a CharField with choices:
class MyModel(models.Model):
THE_CHOICES=(
('val',_(u'Value Description')),
)
...
myfield=models.CharField(max_length=3,choices=THE_CHOICES
Now in the template I access an instance of MyModel:
{{ my_instance.myfield }}
Of course the gives me val instead of Value Description. How do I get the description?
Thanks in advance!
You need to use
{{ my_instance.get_myfield_display }}, as documented here: http://docs.djangoproject.com/en/1.1/ref/models/instances/#django.db.models.Model.get_FOO_display